Skip to content

Commit

Permalink
Merge bitcoindevkit#1597: fix(wallet): do check_wallet_descriptor w…
Browse files Browse the repository at this point in the history
…hen creating and loading

5aecf4d fix(wallet): do `check_wallet_descriptor` when creating and loading (valued mammal)

Pull request description:

  Do `check_wallet_descriptor` for both external and internal descriptors when creating a wallet, and as a defensive measure also perform the check on the descriptors loaded from a changeset.

  fixes bitcoindevkit#1557

  ### 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:
  notmandatory:
    ACK 5aecf4d

Tree-SHA512: c1503cc0350894cff762925276a2b5b94ac07155df8ff85c9277fb33001bc3137f479f1b8b1c5da4401a6a1b7184467915558e1fa761ae7ccef5d8886103cdad
  • Loading branch information
notmandatory committed Sep 11, 2024
2 parents 532f906 + 5aecf4d commit a4b4946
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ impl Wallet {
let (chain, chain_changeset) = LocalChain::from_genesis_hash(genesis_hash);

let (descriptor, mut descriptor_keymap) = (params.descriptor)(&secp, network)?;
check_wallet_descriptor(&descriptor)?;
descriptor_keymap.extend(params.descriptor_keymap);

let signers = Arc::new(SignersContainer::build(
Expand All @@ -401,6 +402,7 @@ impl Wallet {
let (change_descriptor, change_signers) = match params.change_descriptor {
Some(make_desc) => {
let (change_descriptor, mut internal_keymap) = make_desc(&secp, network)?;
check_wallet_descriptor(&change_descriptor)?;
internal_keymap.extend(params.change_descriptor_keymap);
let change_signers = Arc::new(SignersContainer::build(
internal_keymap,
Expand Down Expand Up @@ -582,6 +584,7 @@ impl Wallet {
}
// parameters must match
Some(make_desc) => {
check_wallet_descriptor(&desc).map_err(LoadError::Descriptor)?;
let (exp_desc, keymap) =
make_desc(&secp, network).map_err(LoadError::Descriptor)?;
if desc.descriptor_id() != exp_desc.descriptor_id() {
Expand Down

0 comments on commit a4b4946

Please sign in to comment.