@@ -7,7 +7,6 @@ use core::str::FromStr;
7
7
use std:: error;
8
8
9
9
use bitcoin:: bip32:: { self , XKeyIdentifier } ;
10
- use bitcoin:: hashes:: hex:: FromHex ;
11
10
use bitcoin:: hashes:: { hash160, ripemd160, sha256, Hash , HashEngine } ;
12
11
use bitcoin:: key:: XOnlyPublicKey ;
13
12
use bitcoin:: secp256k1:: { Secp256k1 , Signing , Verification } ;
@@ -906,21 +905,21 @@ impl<K: InnerXKey> DescriptorXKey<K> {
906
905
/// assert_eq!(
907
906
/// xpub.matches(&(
908
907
/// 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(()))?
910
909
/// ), &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(()))?)
912
911
/// );
913
912
/// assert_eq!(
914
913
/// xpub.matches(&(
915
914
/// 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(()))?
917
916
/// ), &ctx),
918
917
/// None
919
918
/// );
920
919
/// assert_eq!(
921
920
/// xpub.matches(&(
922
921
/// 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(()))?
924
923
/// ), &ctx),
925
924
/// None
926
925
/// );
@@ -1234,17 +1233,17 @@ mod test {
1234
1233
fn test_wildcard ( ) {
1235
1234
let public_key = DescriptorPublicKey :: from_str ( "[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2" ) . unwrap ( ) ;
1236
1235
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" ) ;
1238
1237
assert ! ( !public_key. has_wildcard( ) ) ;
1239
1238
1240
1239
let public_key = DescriptorPublicKey :: from_str ( "[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*" ) . unwrap ( ) ;
1241
1240
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'" ) ;
1243
1242
assert ! ( public_key. has_wildcard( ) ) ;
1244
1243
1245
1244
let public_key = DescriptorPublicKey :: from_str ( "[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*h" ) . unwrap ( ) ;
1246
1245
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'" ) ;
1248
1247
assert ! ( public_key. has_wildcard( ) ) ;
1249
1248
}
1250
1249
@@ -1256,32 +1255,32 @@ mod test {
1256
1255
let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
1257
1256
assert_eq ! ( public_key. to_string( ) , "[2cbe2a6d/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2" ) ;
1258
1257
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" ) ;
1260
1259
assert ! ( !public_key. has_wildcard( ) ) ;
1261
1260
1262
1261
let secret_key = DescriptorSecretKey :: from_str ( "tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0'/1'/2'" ) . unwrap ( ) ;
1263
1262
let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
1264
1263
assert_eq ! ( public_key. to_string( ) , "[2cbe2a6d/0'/1'/2']tpubDDPuH46rv4dbFtmF6FrEtJEy1CvLZonyBoVxF6xsesHdYDdTBrq2mHhm8AbsPh39sUwL2nZyxd6vo4uWNTU9v4t893CwxjqPnwMoUACLvMV" ) ;
1265
1264
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'" ) ;
1267
1266
1268
1267
let secret_key = DescriptorSecretKey :: from_str ( "tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0/1/2" ) . unwrap ( ) ;
1269
1268
let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
1270
1269
assert_eq ! ( public_key. to_string( ) , "tpubD6NzVbkrYhZ4WQdzxL7NmJN7b85ePo4p6RSj9QQHF7te2RR9iUeVSGgnGkoUsB9LBRosgvNbjRv9bcsJgzgBd7QKuxDm23ZewkTRzNSLEDr/0/1/2" ) ;
1271
1270
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" ) ;
1273
1272
1274
1273
let secret_key = DescriptorSecretKey :: from_str ( "[aabbccdd]tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0/1/2" ) . unwrap ( ) ;
1275
1274
let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
1276
1275
assert_eq ! ( public_key. to_string( ) , "[aabbccdd]tpubD6NzVbkrYhZ4WQdzxL7NmJN7b85ePo4p6RSj9QQHF7te2RR9iUeVSGgnGkoUsB9LBRosgvNbjRv9bcsJgzgBd7QKuxDm23ZewkTRzNSLEDr/0/1/2" ) ;
1277
1276
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" ) ;
1279
1278
1280
1279
let secret_key = DescriptorSecretKey :: from_str ( "[aabbccdd/90']tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0'/1'/2" ) . unwrap ( ) ;
1281
1280
let public_key = secret_key. to_public ( & secp) . unwrap ( ) ;
1282
1281
assert_eq ! ( public_key. to_string( ) , "[aabbccdd/90'/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2" ) ;
1283
1282
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" ) ;
1285
1284
}
1286
1285
1287
1286
#[ test]
@@ -1323,10 +1322,10 @@ mod test {
1323
1322
assert_eq ! (
1324
1323
xpub. derivation_paths. paths( ) ,
1325
1324
& 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( )
1330
1329
] ,
1331
1330
) ;
1332
1331
assert_eq ! (
@@ -1338,9 +1337,9 @@ mod test {
1338
1337
assert_eq ! (
1339
1338
xpub. derivation_paths. paths( ) ,
1340
1339
& 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( )
1344
1343
] ,
1345
1344
) ;
1346
1345
assert_eq ! (
@@ -1353,9 +1352,9 @@ mod test {
1353
1352
assert_eq ! (
1354
1353
xpub. derivation_paths. paths( ) ,
1355
1354
& 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( )
1359
1358
] ,
1360
1359
) ;
1361
1360
assert_eq ! (
@@ -1368,8 +1367,8 @@ mod test {
1368
1367
assert_eq ! (
1369
1368
xpub. derivation_paths. paths( ) ,
1370
1369
& 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( ) ,
1373
1372
] ,
1374
1373
) ;
1375
1374
assert_eq ! (
@@ -1383,8 +1382,8 @@ mod test {
1383
1382
assert_eq ! (
1384
1383
xpub. derivation_paths. paths( ) ,
1385
1384
& 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( ) ,
1388
1387
] ,
1389
1388
) ;
1390
1389
assert_eq ! (
@@ -1399,8 +1398,8 @@ mod test {
1399
1398
assert_eq ! (
1400
1399
desc_key. full_derivation_paths( ) ,
1401
1400
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( ) ,
1404
1403
] ,
1405
1404
) ;
1406
1405
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 {
1410
1409
assert_eq ! (
1411
1410
xprv. derivation_paths. paths( ) ,
1412
1411
& 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( )
1417
1416
] ,
1418
1417
) ;
1419
1418
assert_eq ! (
@@ -1424,9 +1423,9 @@ mod test {
1424
1423
assert_eq ! (
1425
1424
xprv. derivation_paths. paths( ) ,
1426
1425
& 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( )
1430
1429
] ,
1431
1430
) ;
1432
1431
assert_eq ! (
@@ -1438,9 +1437,9 @@ mod test {
1438
1437
assert_eq ! (
1439
1438
xprv. derivation_paths. paths( ) ,
1440
1439
& 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( )
1444
1443
] ,
1445
1444
) ;
1446
1445
assert_eq ! (
@@ -1452,8 +1451,8 @@ mod test {
1452
1451
assert_eq ! (
1453
1452
xprv. derivation_paths. paths( ) ,
1454
1453
& 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( ) ,
1457
1456
] ,
1458
1457
) ;
1459
1458
assert_eq ! (
@@ -1465,8 +1464,8 @@ mod test {
1465
1464
assert_eq ! (
1466
1465
xprv. derivation_paths. paths( ) ,
1467
1466
& 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( ) ,
1470
1469
] ,
1471
1470
) ;
1472
1471
assert_eq ! (
0 commit comments