From 35579cb2169e0364f5c46043234a19eb23ac5ab6 Mon Sep 17 00:00:00 2001 From: LLFourn Date: Tue, 17 Nov 2020 12:37:53 +1100 Subject: [PATCH] [wallet] Build output lookup inside complete transaction To avoid the caller having to do it. --- src/wallet/mod.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) 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