Skip to content

Commit e8a9638

Browse files
committed
fix(wallet): improve safety on finaize psbt
1 parent 91d7d3c commit e8a9638

File tree

1 file changed

+5
-2
lines changed
  • crates/wallet/src/wallet

1 file changed

+5
-2
lines changed

crates/wallet/src/wallet/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,8 +1879,11 @@ impl Wallet {
18791879
Ok(_) => {
18801880
// Set the UTXO fields, final script_sig and witness
18811881
// and clear everything else.
1882-
let original = mem::take(&mut psbt.inputs[n]);
1883-
let psbt_input = &mut psbt.inputs[n];
1882+
let psbt_input = psbt
1883+
.inputs
1884+
.get_mut(n)
1885+
.ok_or(SignerError::InputIndexOutOfRange)?;
1886+
let original = mem::take(psbt_input);
18841887
psbt_input.non_witness_utxo = original.non_witness_utxo;
18851888
psbt_input.witness_utxo = original.witness_utxo;
18861889
if !tmp_input.script_sig.is_empty() {

0 commit comments

Comments
 (0)