@@ -1037,7 +1037,7 @@ impl DefiniteDescriptorKey {
1037
1037
///
1038
1038
/// Returns `None` if the key contains a wildcard
1039
1039
fn new ( key : DescriptorPublicKey ) -> Option < Self > {
1040
- if key. has_wildcard ( ) {
1040
+ if key. has_wildcard ( ) || key . is_multipath ( ) {
1041
1041
None
1042
1042
} else {
1043
1043
Some ( Self ( key) )
@@ -1071,7 +1071,7 @@ impl FromStr for DefiniteDescriptorKey {
1071
1071
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
1072
1072
let inner = DescriptorPublicKey :: from_str ( s) ?;
1073
1073
DefiniteDescriptorKey :: new ( inner) . ok_or ( DescriptorKeyParseError (
1074
- "cannot parse key with a wilcard as a DerivedDescriptorKey" ,
1074
+ "cannot parse multi-path keys or keys with a wilcard as a DerivedDescriptorKey" ,
1075
1075
) )
1076
1076
}
1077
1077
}
@@ -1150,6 +1150,7 @@ mod test {
1150
1150
MiniscriptKey , Wildcard ,
1151
1151
} ;
1152
1152
use crate :: prelude:: * ;
1153
+ use crate :: DefiniteDescriptorKey ;
1153
1154
1154
1155
#[ test]
1155
1156
fn parse_descriptor_key_errors ( ) {
@@ -1497,4 +1498,23 @@ mod test {
1497
1498
let public_key = DescriptorPublicKey :: from_str ( desc) . unwrap ( ) ;
1498
1499
assert_tokens ( & public_key, & [ Token :: String ( desc) ] ) ;
1499
1500
}
1501
+
1502
+ #[ test]
1503
+ fn definite_keys ( ) {
1504
+ // basic xpub
1505
+ let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"
1506
+ . parse :: < DescriptorPublicKey > ( )
1507
+ . unwrap ( ) ;
1508
+ assert ! ( DefiniteDescriptorKey :: new( desc) . is_some( ) ) ;
1509
+ // xpub with wildcard
1510
+ let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*"
1511
+ . parse :: < DescriptorPublicKey > ( )
1512
+ . unwrap ( ) ;
1513
+ assert ! ( DefiniteDescriptorKey :: new( desc) . is_none( ) ) ;
1514
+ // multipath xpub
1515
+ let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/<0;1>"
1516
+ . parse :: < DescriptorPublicKey > ( )
1517
+ . unwrap ( ) ;
1518
+ assert ! ( DefiniteDescriptorKey :: new( desc) . is_none( ) ) ;
1519
+ }
1500
1520
}
0 commit comments