You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Test that 2-path multipath descriptor passes validation
987
+
let descriptor_str = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/<0;1>/*)";
let result = check_wallet_descriptor(&descriptor);
993
+
assert!(result.is_ok());
994
+
995
+
// Test that 1-path descriptor (non-multipath) still works
996
+
let descriptor_str = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/0/*)";
997
+
let(descriptor, _) = descriptor_str
998
+
.into_wallet_descriptor(&secp,Network::Testnet)
999
+
.expect("should parse single-path descriptor");
1000
+
1001
+
let result = check_wallet_descriptor(&descriptor);
1002
+
assert!(result.is_ok());
1003
+
1004
+
// Test that 3-path multipath descriptor fails validation
1005
+
let descriptor_str = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/<0;1;2>/*)";
let multipath_descriptor = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/<0;1>/*)";
2811
+
2812
+
// Test successful creation of multipath wallet
2813
+
let params = Wallet::create_multipath(multipath_descriptor);
2814
+
let wallet = params.network(Network::Testnet).create_wallet_no_persist();
2815
+
assert!(wallet.is_ok());
2816
+
2817
+
let wallet = wallet.unwrap();
2818
+
2819
+
// Verify that the wallet has both external and internal keychains
2820
+
let keychains:Vec<_> = wallet.keychains().collect();
2821
+
assert_eq!(keychains.len(),2);
2822
+
2823
+
// Verify that the descriptors are different (receive vs change)
let single_path_descriptor = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/0/*)";
2846
+
let params = Wallet::create_multipath(single_path_descriptor);
2847
+
let wallet = params.network(Network::Testnet).create_wallet_no_persist();
let three_path_descriptor = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/<0;1;2>/*)";
2852
+
let params = Wallet::create_multipath(three_path_descriptor);
2853
+
let wallet = params.network(Network::Testnet).create_wallet_no_persist();
0 commit comments