@@ -1038,7 +1038,7 @@ impl DefiniteDescriptorKey {
1038
1038
///
1039
1039
/// Returns `None` if the key contains a wildcard
1040
1040
fn new ( key : DescriptorPublicKey ) -> Option < Self > {
1041
- if key. has_wildcard ( ) {
1041
+ if key. has_wildcard ( ) || key . is_multipath ( ) {
1042
1042
None
1043
1043
} else {
1044
1044
Some ( Self ( key) )
@@ -1072,7 +1072,7 @@ impl FromStr for DefiniteDescriptorKey {
1072
1072
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
1073
1073
let inner = DescriptorPublicKey :: from_str ( s) ?;
1074
1074
DefiniteDescriptorKey :: new ( inner) . ok_or ( DescriptorKeyParseError (
1075
- "cannot parse key with a wilcard as a DerivedDescriptorKey" ,
1075
+ "cannot parse multi-path keys or keys with a wilcard as a DerivedDescriptorKey" ,
1076
1076
) )
1077
1077
}
1078
1078
}
@@ -1150,7 +1150,7 @@ mod test {
1150
1150
DescriptorKeyParseError , DescriptorMultiXKey , DescriptorPublicKey , DescriptorSecretKey ,
1151
1151
MiniscriptKey , Wildcard ,
1152
1152
} ;
1153
- use crate :: prelude:: * ;
1153
+ use crate :: { prelude:: * , DefiniteDescriptorKey } ;
1154
1154
1155
1155
#[ test]
1156
1156
fn parse_descriptor_key_errors ( ) {
@@ -1498,4 +1498,23 @@ mod test {
1498
1498
let public_key = DescriptorPublicKey :: from_str ( desc) . unwrap ( ) ;
1499
1499
assert_tokens ( & public_key, & [ Token :: String ( desc) ] ) ;
1500
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
+ }
1501
1520
}
0 commit comments