Skip to content

Commit b2876d8

Browse files
committed
Merge #1790: fix(wallet): improve safety on finaize psbt
e8a9638 fix(wallet): improve safety on finaize psbt (f3r10) Pull request description: <!-- You can erase any parts of this template not applicable to your Pull Request. --> fix #1711 ### Description This PR replaces how currently potentially bug-prone PSBT's input access is done using a more carefully approach. ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ### Changelog notice <!-- Notice the release manager should include in the release tag message changelog --> <!-- See https://keepachangelog.com/en/1.0.0/ for examples --> ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: rustaceanrob: ACK e8a9638 evanlinjin: ACK e8a9638 Tree-SHA512: ad25a9d5d47cbdc41b11ea4ce57b30c6855ea391c0f053dffbee0c3dd1b06c6b227e056ede69eee6026e8b72915fe06c366d0a4e2fd6a1d454fc8dafed80b74a
2 parents abc3056 + e8a9638 commit b2876d8

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
@@ -1901,8 +1901,11 @@ impl Wallet {
19011901
Ok(_) => {
19021902
// Set the UTXO fields, final script_sig and witness
19031903
// and clear everything else.
1904-
let original = mem::take(&mut psbt.inputs[n]);
1905-
let psbt_input = &mut psbt.inputs[n];
1904+
let psbt_input = psbt
1905+
.inputs
1906+
.get_mut(n)
1907+
.ok_or(SignerError::InputIndexOutOfRange)?;
1908+
let original = mem::take(psbt_input);
19061909
psbt_input.non_witness_utxo = original.non_witness_utxo;
19071910
psbt_input.witness_utxo = original.witness_utxo;
19081911
if !tmp_input.script_sig.is_empty() {

0 commit comments

Comments
 (0)