Skip to content

Multipath descriptor network association wrong #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andreasgriffin opened this issue Feb 19, 2025 · 4 comments · Fixed by #241
Closed

Multipath descriptor network association wrong #10

andreasgriffin opened this issue Feb 19, 2025 · 4 comments · Fixed by #241
Assignees
Labels
bug Something isn't working
Milestone

Comments

@andreasgriffin
Copy link

andreasgriffin commented Feb 19, 2025

Describe the bug

The into_wallet_descriptor function takes a network argument which should doublecheck if the descriptor fits this network. However this doesn't work as expected.

use bdk_wallet::bitcoin::key::Secp256k1;
use bdk_wallet::bitcoin::Network;
use bdk_wallet::descriptor::{ExtendedDescriptor, IntoWalletDescriptor};
use bdk_wallet::keys::KeyMap;
use bdk_wallet::miniscript::TranslatePk;
 

fn main() {  
    // multipath
    let descriptor_str = "wpkh([9a6a2580/84'/0'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/<0;1>/*)";

    let secp = Secp256k1::new();
    let (extended_descriptor, key_map) = descriptor_str
        .into_wallet_descriptor(&secp,  Network::Testnet)
        .unwrap();

    println!("working: {}", extended_descriptor.to_string());

 

    // multipath  should not work, but throws no error
    let descriptor_str = "wpkh([9a6a2580/84'/0'/0']xpub6DEzNop46vmxR49zYWFnMwmEfawSNmAMf6dLH5YKDY463twtvw1XD7ihwJRLPRGZJz799VPFzXHpZu6WdhT29WnaeuChS6aZHZPFmqczR5K/<0;1>/*)";

    let secp = Secp256k1::new();
    let (extended_descriptor, key_map) = descriptor_str
        .into_wallet_descriptor(&secp,  Network::Testnet)
        .unwrap();

    println!("should not work: {}", extended_descriptor.to_string());

     // multipath  should work, but fails
     let descriptor_str = "wpkh([9a6a2580/84'/0'/0']xpub6DEzNop46vmxR49zYWFnMwmEfawSNmAMf6dLH5YKDY463twtvw1XD7ihwJRLPRGZJz799VPFzXHpZu6WdhT29WnaeuChS6aZHZPFmqczR5K/<0;1>/*)";

     let secp = Secp256k1::new();
     let (extended_descriptor, key_map) = descriptor_str
         .into_wallet_descriptor(&secp,  Network::Bitcoin)
         .unwrap();
 
    println!("fail: {}", extended_descriptor.to_string());
 
  
}

This error (in the 3. case) only occurs with multipath descriptors.

Build environment

[dependencies]
bdk_wallet = { version = "1.0.0", features = ["all-keys", "keys-bip39", "rusqlite"] }
bdk_core = { version = "0.4.1" }

@andreasgriffin andreasgriffin added the bug Something isn't working label Feb 19, 2025
@notmandatory notmandatory moved this to Todo in BDK Wallet Feb 19, 2025
@notmandatory
Copy link
Member

notmandatory commented Feb 19, 2025

We don't currently support multipath descriptors in bdk_wallet but do have the issue #11 you opened to support them. It's likely a small-ish change. We have had other's request this feature so I agree it should be a higher priority.

@andreasgriffin
Copy link
Author

bdk_wallet::descriptor does work with multi-path descriptors already, and as such it should do the network association correctly.

@notmandatory
Copy link
Member

I added this to the 1.2 milestone for visibility.

@notmandatory
Copy link
Member

This should be fixed with #11 rather than by itself.

@ValuedMammal ValuedMammal self-assigned this Mar 11, 2025
@ValuedMammal ValuedMammal moved this from Todo to In Progress in BDK Wallet Mar 20, 2025
@notmandatory notmandatory moved this from In Progress to Needs Review in BDK Wallet Mar 20, 2025
@ValuedMammal ValuedMammal added this to the 1.3.0 milestone Apr 3, 2025
@notmandatory notmandatory transferred this issue from bitcoindevkit/bdk Apr 4, 2025
@ValuedMammal ValuedMammal moved this from Needs Review to In Progress in BDK Wallet Apr 8, 2025
@notmandatory notmandatory moved this from In Progress to Todo in BDK Wallet Apr 24, 2025
@notmandatory notmandatory moved this from Todo to Needs Review in BDK Wallet May 27, 2025
@github-project-automation github-project-automation bot moved this from Needs Review to Done in BDK Wallet May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
3 participants