From: LLFourn Date: Tue, 17 Nov 2020 01:37:53 +0000 (+1100) Subject: [wallet] Build output lookup inside complete transaction X-Git-Tag: v0.2.0~66 X-Git-Url: http://internal-gitweb-vhost/parse/src/example_cli/%22https:/struct.DecoderReader.html?a=commitdiff_plain;h=35579cb2169e0364f5c46043234a19eb23ac5ab6;p=bdk [wallet] Build output lookup inside complete transaction To avoid the caller having to do it. --- diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index d09ec152..34c5ac0d 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -484,11 +484,7 @@ where builder.ordering.sort_tx(&mut tx); let txid = tx.txid(); - let lookup_output = selected - .into_iter() - .map(|utxo| (utxo.outpoint, utxo)) - .collect(); - let psbt = self.complete_transaction(tx, lookup_output, builder)?; + let psbt = self.complete_transaction(tx, selected, builder)?; let transaction_details = TransactionDetails { transaction: None, @@ -771,14 +767,10 @@ where // TODO: check that we are not replacing more than 100 txs from mempool details.txid = tx.txid(); - let lookup_output = selected - .into_iter() - .map(|utxo| (utxo.outpoint, utxo)) - .collect(); details.fees = fee_amount; details.timestamp = time::get_timestamp(); - let psbt = self.complete_transaction(tx, lookup_output, builder)?; + let psbt = self.complete_transaction(tx, selected, builder)?; Ok((psbt, details)) } @@ -1131,10 +1123,14 @@ where >( &self, tx: Transaction, - lookup_output: HashMap, + selected: Vec, builder: TxBuilder, ) -> Result { let mut psbt = PSBT::from_unsigned_tx(tx)?; + let lookup_output = selected + .into_iter() + .map(|utxo| (utxo.outpoint, utxo)) + .collect::>(); // add metadata for the inputs for (psbt_input, input) in psbt