@@ -1058,7 +1058,7 @@ impl DefiniteDescriptorKey {
1058
1058
///
1059
1059
/// Returns `None` if the key contains a wildcard
1060
1060
fn new ( key : DescriptorPublicKey ) -> Option < Self > {
1061
- if key. has_wildcard ( ) {
1061
+ if key. has_wildcard ( ) || key . is_multipath ( ) {
1062
1062
None
1063
1063
} else {
1064
1064
Some ( Self ( key) )
@@ -1092,7 +1092,7 @@ impl FromStr for DefiniteDescriptorKey {
1092
1092
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
1093
1093
let inner = DescriptorPublicKey :: from_str ( s) ?;
1094
1094
DefiniteDescriptorKey :: new ( inner) . ok_or ( DescriptorKeyParseError (
1095
- "cannot parse key with a wilcard as a DerivedDescriptorKey" ,
1095
+ "cannot parse multi-path keys or keys with a wilcard as a DerivedDescriptorKey" ,
1096
1096
) )
1097
1097
}
1098
1098
}
@@ -1190,7 +1190,7 @@ mod test {
1190
1190
DescriptorKeyParseError , DescriptorMultiXKey , DescriptorPublicKey , DescriptorSecretKey ,
1191
1191
MiniscriptKey , Wildcard ,
1192
1192
} ;
1193
- use crate :: prelude:: * ;
1193
+ use crate :: { prelude:: * , DefiniteDescriptorKey } ;
1194
1194
1195
1195
#[ test]
1196
1196
fn parse_descriptor_key_errors ( ) {
@@ -1571,4 +1571,23 @@ mod test {
1571
1571
let public_key = DescriptorPublicKey :: from_str ( desc) . unwrap ( ) ;
1572
1572
assert_tokens ( & public_key, & [ Token :: String ( desc) ] ) ;
1573
1573
}
1574
+
1575
+ #[ test]
1576
+ fn definite_keys ( ) {
1577
+ // basic xpub
1578
+ let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"
1579
+ . parse :: < DescriptorPublicKey > ( )
1580
+ . unwrap ( ) ;
1581
+ assert ! ( DefiniteDescriptorKey :: new( desc) . is_some( ) ) ;
1582
+ // xpub with wildcard
1583
+ let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*"
1584
+ . parse :: < DescriptorPublicKey > ( )
1585
+ . unwrap ( ) ;
1586
+ assert ! ( DefiniteDescriptorKey :: new( desc) . is_none( ) ) ;
1587
+ // multipath xpub
1588
+ let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/<0;1>"
1589
+ . parse :: < DescriptorPublicKey > ( )
1590
+ . unwrap ( ) ;
1591
+ assert ! ( DefiniteDescriptorKey :: new( desc) . is_none( ) ) ;
1592
+ }
1574
1593
}
0 commit comments