@@ -7,7 +7,6 @@ use core::str::FromStr;
77use std:: error;
88
99use bitcoin:: bip32:: { self , XKeyIdentifier } ;
10- use bitcoin:: hashes:: hex:: FromHex ;
1110use bitcoin:: hashes:: { hash160, ripemd160, sha256, Hash , HashEngine } ;
1211use bitcoin:: key:: XOnlyPublicKey ;
1312use bitcoin:: secp256k1:: { Secp256k1 , Signing , Verification } ;
@@ -906,21 +905,21 @@ impl<K: InnerXKey> DescriptorXKey<K> {
906905 /// assert_eq!(
907906 /// xpub.matches(&(
908907 /// bip32::Fingerprint::from_str("d34db33f").or(Err(()))?,
909- /// bip32::DerivationPath::from_str("m/ 44'/0'/0'/1/42").or(Err(()))?
908+ /// bip32::DerivationPath::from_str("44'/0'/0'/1/42").or(Err(()))?
910909 /// ), &ctx),
911- /// Some(bip32::DerivationPath::from_str("m/ 44'/0'/0'/1").or(Err(()))?)
910+ /// Some(bip32::DerivationPath::from_str("44'/0'/0'/1").or(Err(()))?)
912911 /// );
913912 /// assert_eq!(
914913 /// xpub.matches(&(
915914 /// bip32::Fingerprint::from_str("ffffffff").or(Err(()))?,
916- /// bip32::DerivationPath::from_str("m/ 44'/0'/0'/1/42").or(Err(()))?
915+ /// bip32::DerivationPath::from_str("44'/0'/0'/1/42").or(Err(()))?
917916 /// ), &ctx),
918917 /// None
919918 /// );
920919 /// assert_eq!(
921920 /// xpub.matches(&(
922921 /// bip32::Fingerprint::from_str("d34db33f").or(Err(()))?,
923- /// bip32::DerivationPath::from_str("m/ 44'/0'/0'/100/0").or(Err(()))?
922+ /// bip32::DerivationPath::from_str("44'/0'/0'/100/0").or(Err(()))?
924923 /// ), &ctx),
925924 /// None
926925 /// );
@@ -1234,17 +1233,17 @@ mod test {
12341233 fn test_wildcard ( ) {
12351234 let public_key = DescriptorPublicKey :: from_str ( "[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2" ) . unwrap ( ) ;
12361235 assert_eq ! ( public_key. master_fingerprint( ) . to_string( ) , "abcdef00" ) ;
1237- assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "m/ 0'/1'/2" ) ;
1236+ assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "0'/1'/2" ) ;
12381237 assert ! ( !public_key. has_wildcard( ) ) ;
12391238
12401239 let public_key = DescriptorPublicKey :: from_str ( "[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*" ) . unwrap ( ) ;
12411240 assert_eq ! ( public_key. master_fingerprint( ) . to_string( ) , "abcdef00" ) ;
1242- assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "m/ 0'/1'" ) ;
1241+ assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "0'/1'" ) ;
12431242 assert ! ( public_key. has_wildcard( ) ) ;
12441243
12451244 let public_key = DescriptorPublicKey :: from_str ( "[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*h" ) . unwrap ( ) ;
12461245 assert_eq ! ( public_key. master_fingerprint( ) . to_string( ) , "abcdef00" ) ;
1247- assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "m/ 0'/1'" ) ;
1246+ assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "0'/1'" ) ;
12481247 assert ! ( public_key. has_wildcard( ) ) ;
12491248 }
12501249
@@ -1256,32 +1255,32 @@ mod test {
12561255 let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
12571256 assert_eq ! ( public_key. to_string( ) , "[2cbe2a6d/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2" ) ;
12581257 assert_eq ! ( public_key. master_fingerprint( ) . to_string( ) , "2cbe2a6d" ) ;
1259- assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "m/ 0'/1'/2" ) ;
1258+ assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "0'/1'/2" ) ;
12601259 assert ! ( !public_key. has_wildcard( ) ) ;
12611260
12621261 let secret_key = DescriptorSecretKey :: from_str ( "tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0'/1'/2'" ) . unwrap ( ) ;
12631262 let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
12641263 assert_eq ! ( public_key. to_string( ) , "[2cbe2a6d/0'/1'/2']tpubDDPuH46rv4dbFtmF6FrEtJEy1CvLZonyBoVxF6xsesHdYDdTBrq2mHhm8AbsPh39sUwL2nZyxd6vo4uWNTU9v4t893CwxjqPnwMoUACLvMV" ) ;
12651264 assert_eq ! ( public_key. master_fingerprint( ) . to_string( ) , "2cbe2a6d" ) ;
1266- assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "m/ 0'/1'/2'" ) ;
1265+ assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "0'/1'/2'" ) ;
12671266
12681267 let secret_key = DescriptorSecretKey :: from_str ( "tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0/1/2" ) . unwrap ( ) ;
12691268 let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
12701269 assert_eq ! ( public_key. to_string( ) , "tpubD6NzVbkrYhZ4WQdzxL7NmJN7b85ePo4p6RSj9QQHF7te2RR9iUeVSGgnGkoUsB9LBRosgvNbjRv9bcsJgzgBd7QKuxDm23ZewkTRzNSLEDr/0/1/2" ) ;
12711270 assert_eq ! ( public_key. master_fingerprint( ) . to_string( ) , "2cbe2a6d" ) ;
1272- assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "m/ 0/1/2" ) ;
1271+ assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "0/1/2" ) ;
12731272
12741273 let secret_key = DescriptorSecretKey :: from_str ( "[aabbccdd]tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0/1/2" ) . unwrap ( ) ;
12751274 let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
12761275 assert_eq ! ( public_key. to_string( ) , "[aabbccdd]tpubD6NzVbkrYhZ4WQdzxL7NmJN7b85ePo4p6RSj9QQHF7te2RR9iUeVSGgnGkoUsB9LBRosgvNbjRv9bcsJgzgBd7QKuxDm23ZewkTRzNSLEDr/0/1/2" ) ;
12771276 assert_eq ! ( public_key. master_fingerprint( ) . to_string( ) , "aabbccdd" ) ;
1278- assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "m/ 0/1/2" ) ;
1277+ assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "0/1/2" ) ;
12791278
12801279 let secret_key = DescriptorSecretKey :: from_str ( "[aabbccdd/90']tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0'/1'/2" ) . unwrap ( ) ;
12811280 let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
12821281 assert_eq ! ( public_key. to_string( ) , "[aabbccdd/90'/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2" ) ;
12831282 assert_eq ! ( public_key. master_fingerprint( ) . to_string( ) , "aabbccdd" ) ;
1284- assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "m/ 90'/0'/1'/2" ) ;
1283+ assert_eq ! ( public_key. full_derivation_path( ) . unwrap( ) . to_string( ) , "90'/0'/1'/2" ) ;
12851284 }
12861285
12871286 #[ test]
@@ -1323,10 +1322,10 @@ mod test {
13231322 assert_eq ! (
13241323 xpub. derivation_paths. paths( ) ,
13251324 & vec![
1326- bip32:: DerivationPath :: from_str( "m/ 2/0" ) . unwrap( ) ,
1327- bip32:: DerivationPath :: from_str( "m/ 2/1" ) . unwrap( ) ,
1328- bip32:: DerivationPath :: from_str( "m/ 2/42" ) . unwrap( ) ,
1329- bip32:: DerivationPath :: from_str( "m/ 2/9854" ) . unwrap( )
1325+ bip32:: DerivationPath :: from_str( "2/0" ) . unwrap( ) ,
1326+ bip32:: DerivationPath :: from_str( "2/1" ) . unwrap( ) ,
1327+ bip32:: DerivationPath :: from_str( "2/42" ) . unwrap( ) ,
1328+ bip32:: DerivationPath :: from_str( "2/9854" ) . unwrap( )
13301329 ] ,
13311330 ) ;
13321331 assert_eq ! (
@@ -1338,9 +1337,9 @@ mod test {
13381337 assert_eq ! (
13391338 xpub. derivation_paths. paths( ) ,
13401339 & vec![
1341- bip32:: DerivationPath :: from_str( "m/ 2/0/0/5/10" ) . unwrap( ) ,
1342- bip32:: DerivationPath :: from_str( "m/ 2/1/0/5/10" ) . unwrap( ) ,
1343- bip32:: DerivationPath :: from_str( "m/ 2/9854/0/5/10" ) . unwrap( )
1340+ bip32:: DerivationPath :: from_str( "2/0/0/5/10" ) . unwrap( ) ,
1341+ bip32:: DerivationPath :: from_str( "2/1/0/5/10" ) . unwrap( ) ,
1342+ bip32:: DerivationPath :: from_str( "2/9854/0/5/10" ) . unwrap( )
13441343 ] ,
13451344 ) ;
13461345 assert_eq ! (
@@ -1353,9 +1352,9 @@ mod test {
13531352 assert_eq ! (
13541353 xpub. derivation_paths. paths( ) ,
13551354 & vec![
1356- bip32:: DerivationPath :: from_str( "m/ 2/0/3456/9876" ) . unwrap( ) ,
1357- bip32:: DerivationPath :: from_str( "m/ 2/1/3456/9876" ) . unwrap( ) ,
1358- bip32:: DerivationPath :: from_str( "m/ 2/9854/3456/9876" ) . unwrap( )
1355+ bip32:: DerivationPath :: from_str( "2/0/3456/9876" ) . unwrap( ) ,
1356+ bip32:: DerivationPath :: from_str( "2/1/3456/9876" ) . unwrap( ) ,
1357+ bip32:: DerivationPath :: from_str( "2/9854/3456/9876" ) . unwrap( )
13591358 ] ,
13601359 ) ;
13611360 assert_eq ! (
@@ -1368,8 +1367,8 @@ mod test {
13681367 assert_eq ! (
13691368 xpub. derivation_paths. paths( ) ,
13701369 & vec![
1371- bip32:: DerivationPath :: from_str( "m/ 0" ) . unwrap( ) ,
1372- bip32:: DerivationPath :: from_str( "m/ 1" ) . unwrap( ) ,
1370+ bip32:: DerivationPath :: from_str( "0" ) . unwrap( ) ,
1371+ bip32:: DerivationPath :: from_str( "1" ) . unwrap( ) ,
13731372 ] ,
13741373 ) ;
13751374 assert_eq ! (
@@ -1383,8 +1382,8 @@ mod test {
13831382 assert_eq ! (
13841383 xpub. derivation_paths. paths( ) ,
13851384 & vec![
1386- bip32:: DerivationPath :: from_str( "m/ 9478'/0'/8'" ) . unwrap( ) ,
1387- bip32:: DerivationPath :: from_str( "m/ 9478h/1h/8h" ) . unwrap( ) ,
1385+ bip32:: DerivationPath :: from_str( "9478'/0'/8'" ) . unwrap( ) ,
1386+ bip32:: DerivationPath :: from_str( "9478h/1h/8h" ) . unwrap( ) ,
13881387 ] ,
13891388 ) ;
13901389 assert_eq ! (
@@ -1399,8 +1398,8 @@ mod test {
13991398 assert_eq ! (
14001399 desc_key. full_derivation_paths( ) ,
14011400 vec![
1402- bip32:: DerivationPath :: from_str( "m/ 0'/1'/9478'/0'/8'" ) . unwrap( ) ,
1403- bip32:: DerivationPath :: from_str( "m/ 0'/1'/9478'/1/8'" ) . unwrap( ) ,
1401+ bip32:: DerivationPath :: from_str( "0'/1'/9478'/0'/8'" ) . unwrap( ) ,
1402+ bip32:: DerivationPath :: from_str( "0'/1'/9478'/1/8'" ) . unwrap( ) ,
14041403 ] ,
14051404 ) ;
14061405 assert_eq ! ( desc_key. into_single_keys( ) , vec![ DescriptorPublicKey :: from_str( "[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/9478'/0'/8h/*'" ) . unwrap( ) , DescriptorPublicKey :: from_str( "[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/9478'/1/8h/*'" ) . unwrap( ) ] ) ;
@@ -1410,10 +1409,10 @@ mod test {
14101409 assert_eq ! (
14111410 xprv. derivation_paths. paths( ) ,
14121411 & vec![
1413- bip32:: DerivationPath :: from_str( "m/ 2/0" ) . unwrap( ) ,
1414- bip32:: DerivationPath :: from_str( "m/ 2/1" ) . unwrap( ) ,
1415- bip32:: DerivationPath :: from_str( "m/ 2/42" ) . unwrap( ) ,
1416- bip32:: DerivationPath :: from_str( "m/ 2/9854" ) . unwrap( )
1412+ bip32:: DerivationPath :: from_str( "2/0" ) . unwrap( ) ,
1413+ bip32:: DerivationPath :: from_str( "2/1" ) . unwrap( ) ,
1414+ bip32:: DerivationPath :: from_str( "2/42" ) . unwrap( ) ,
1415+ bip32:: DerivationPath :: from_str( "2/9854" ) . unwrap( )
14171416 ] ,
14181417 ) ;
14191418 assert_eq ! (
@@ -1424,9 +1423,9 @@ mod test {
14241423 assert_eq ! (
14251424 xprv. derivation_paths. paths( ) ,
14261425 & vec![
1427- bip32:: DerivationPath :: from_str( "m/ 2/0/0/5/10" ) . unwrap( ) ,
1428- bip32:: DerivationPath :: from_str( "m/ 2/1/0/5/10" ) . unwrap( ) ,
1429- bip32:: DerivationPath :: from_str( "m/ 2/9854/0/5/10" ) . unwrap( )
1426+ bip32:: DerivationPath :: from_str( "2/0/0/5/10" ) . unwrap( ) ,
1427+ bip32:: DerivationPath :: from_str( "2/1/0/5/10" ) . unwrap( ) ,
1428+ bip32:: DerivationPath :: from_str( "2/9854/0/5/10" ) . unwrap( )
14301429 ] ,
14311430 ) ;
14321431 assert_eq ! (
@@ -1438,9 +1437,9 @@ mod test {
14381437 assert_eq ! (
14391438 xprv. derivation_paths. paths( ) ,
14401439 & vec![
1441- bip32:: DerivationPath :: from_str( "m/ 2/0/3456/9876" ) . unwrap( ) ,
1442- bip32:: DerivationPath :: from_str( "m/ 2/1/3456/9876" ) . unwrap( ) ,
1443- bip32:: DerivationPath :: from_str( "m/ 2/9854/3456/9876" ) . unwrap( )
1440+ bip32:: DerivationPath :: from_str( "2/0/3456/9876" ) . unwrap( ) ,
1441+ bip32:: DerivationPath :: from_str( "2/1/3456/9876" ) . unwrap( ) ,
1442+ bip32:: DerivationPath :: from_str( "2/9854/3456/9876" ) . unwrap( )
14441443 ] ,
14451444 ) ;
14461445 assert_eq ! (
@@ -1452,8 +1451,8 @@ mod test {
14521451 assert_eq ! (
14531452 xprv. derivation_paths. paths( ) ,
14541453 & vec![
1455- bip32:: DerivationPath :: from_str( "m/ 0" ) . unwrap( ) ,
1456- bip32:: DerivationPath :: from_str( "m/ 1" ) . unwrap( ) ,
1454+ bip32:: DerivationPath :: from_str( "0" ) . unwrap( ) ,
1455+ bip32:: DerivationPath :: from_str( "1" ) . unwrap( ) ,
14571456 ] ,
14581457 ) ;
14591458 assert_eq ! (
@@ -1465,8 +1464,8 @@ mod test {
14651464 assert_eq ! (
14661465 xprv. derivation_paths. paths( ) ,
14671466 & vec![
1468- bip32:: DerivationPath :: from_str( "m/ 9478'/0'/8'" ) . unwrap( ) ,
1469- bip32:: DerivationPath :: from_str( "m/ 9478h/1h/8h" ) . unwrap( ) ,
1467+ bip32:: DerivationPath :: from_str( "9478'/0'/8'" ) . unwrap( ) ,
1468+ bip32:: DerivationPath :: from_str( "9478h/1h/8h" ) . unwrap( ) ,
14701469 ] ,
14711470 ) ;
14721471 assert_eq ! (
0 commit comments