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
use bdk_wallet::{bitcoin::Network, rusqlite::Connection};
672
+
673
+
#[test]
674
+
fntest_is_multipath_descriptor(){
675
+
let multipath_desc = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/<0;1>/*)";
676
+
let desc = "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/0/*)#429nsxmg";
677
+
let multi_path = is_multipath_desc(multipath_desc);
678
+
let result = is_multipath_desc(desc);
679
+
assert!(multi_path);
680
+
assert!(!result);
681
+
}
682
+
683
+
#[test]
684
+
fntest_multipath_detection_and_initialization(){
685
+
let network = Network::Testnet;
686
+
let multipath_desc = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/<0;1>/*)";
687
+
letmut db = Connection::open_in_memory().expect("should open in memory db");
let result = new_persisted_wallet(network,&mut db,&opts);
698
+
assert!(result.is_ok(),"Multipath initialization should succeed");
699
+
700
+
let wallet = result.unwrap();
701
+
let ext_desc = wallet.public_descriptor(KeychainKind::External).to_string();
702
+
let int_desc = wallet.public_descriptor(KeychainKind::Internal).to_string();
703
+
704
+
assert!(ext_desc.contains("/0/*"),"External should use index 0");
705
+
assert!(int_desc.contains("/1/*"),"Internal should use index 1");
706
+
707
+
assert!(ext_desc.contains("9a6a2580"));
708
+
assert!(int_desc.contains("9a6a2580"));
709
+
}
710
+
711
+
#[test]
712
+
fntest_error_on_ambiguous_descriptors(){
713
+
let network = Network::Testnet;
714
+
let multipath_desc = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/<0;1>/*)";
715
+
let internal_desc = "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/1/*)#y7qjdnts";
716
+
717
+
letmut db = Connection::open_in_memory().expect("should open in memory db");
0 commit comments