Skip to content

Commit

Permalink
fix(wallet): improve safety on finaize psbt
Browse files Browse the repository at this point in the history
  • Loading branch information
f3r10 committed Jan 5, 2025
1 parent 91d7d3c commit e8a9638
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1879,8 +1879,11 @@ impl Wallet {
Ok(_) => {
// Set the UTXO fields, final script_sig and witness
// and clear everything else.
let original = mem::take(&mut psbt.inputs[n]);
let psbt_input = &mut psbt.inputs[n];
let psbt_input = psbt
.inputs
.get_mut(n)
.ok_or(SignerError::InputIndexOutOfRange)?;
let original = mem::take(psbt_input);
psbt_input.non_witness_utxo = original.non_witness_utxo;
psbt_input.witness_utxo = original.witness_utxo;
if !tmp_input.script_sig.is_empty() {
Expand Down

0 comments on commit e8a9638

Please sign in to comment.