diff --git a/crates/wallet/src/wallet/mod.rs b/crates/wallet/src/wallet/mod.rs index 4adfb633f..54c2b51f2 100644 --- a/crates/wallet/src/wallet/mod.rs +++ b/crates/wallet/src/wallet/mod.rs @@ -1383,8 +1383,6 @@ impl Wallet { } let mut outgoing = Amount::ZERO; - let mut received = Amount::ZERO; - let recipients = params.recipients.iter().map(|(r, v)| (r, *v)); for (index, (script_pubkey, value)) in recipients.enumerate() { @@ -1392,10 +1390,6 @@ impl Wallet { return Err(CreateTxError::OutputBelowDustLimit(index)); } - if self.is_mine(script_pubkey.clone()) { - received += value; - } - let new_out = TxOut { script_pubkey: script_pubkey.clone(), value, @@ -1451,9 +1445,8 @@ impl Wallet { rng, ) .map_err(CreateTxError::CoinSelection)?; - fee_amount += coin_selection.fee_amount; - let excess = &coin_selection.excess; + let excess = &coin_selection.excess; tx.input = coin_selection .selected .iter() @@ -1492,28 +1485,19 @@ impl Wallet { } } - match excess { - Excess::NoChange { - remaining_amount, .. - } => fee_amount += *remaining_amount, - Excess::Change { amount, fee } => { - if self.is_mine(drain_script.clone()) { - received += *amount; - } - fee_amount += *fee; - - // create drain output - let drain_output = TxOut { - value: *amount, - script_pubkey: drain_script, - }; + // if there's change, create and add a change output + if let Excess::Change { amount, .. } = excess { + // create drain output + let drain_output = TxOut { + value: *amount, + script_pubkey: drain_script, + }; - // TODO: We should pay attention when adding a new output: this might increase - // the length of the "number of vouts" parameter by 2 bytes, potentially making - // our feerate too low - tx.output.push(drain_output); - } - }; + // TODO: We should pay attention when adding a new output: this might increase + // the length of the "number of vouts" parameter by 2 bytes, potentially making + // our feerate too low + tx.output.push(drain_output); + } // sort input/outputs according to the chosen algorithm params.ordering.sort_tx_with_aux_rand(&mut tx, rng);