From: f3r10 Date: Sun, 5 Jan 2025 17:55:49 +0000 (-0500) Subject: fix(wallet): improve safety on finaize psbt X-Git-Tag: bitcoind_rpc-0.18.0~13^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/static/struct.CommandStringError.html?a=commitdiff_plain;h=e8a96389bac78961220cbc095c820a551ce4dacf;p=bdk fix(wallet): improve safety on finaize psbt --- diff --git a/crates/wallet/src/wallet/mod.rs b/crates/wallet/src/wallet/mod.rs index 68d5e6be..55922594 100644 --- a/crates/wallet/src/wallet/mod.rs +++ b/crates/wallet/src/wallet/mod.rs @@ -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() {