@@ -388,15 +388,15 @@ where
388
388
/// Parse an expression tree into a descriptor
389
389
fn from_tree ( top : & expression:: Tree ) -> Result < Descriptor < Pk > , Error > {
390
390
match ( top. name , top. args . len ( ) as u32 ) {
391
- ( "pk" , 1 ) => {
392
- expression :: terminal ( & top . args [ 0 ] , |pk| Pk :: from_str ( pk) . map ( Descriptor :: Pk ) )
393
- }
394
- ( "pkh" , 1 ) => {
395
- expression :: terminal ( & top . args [ 0 ] , |pk| Pk :: from_str ( pk) . map ( Descriptor :: Pkh ) )
396
- }
397
- ( "wpkh" , 1 ) => {
398
- expression :: terminal ( & top . args [ 0 ] , |pk| Pk :: from_str ( pk) . map ( Descriptor :: Wpkh ) )
399
- }
391
+ ( "pk" , 1 ) => expression :: terminal ( & top . args [ 0 ] , |pk| {
392
+ MiniscriptKey :: from_str ( pk, false ) . map ( Descriptor :: Pk )
393
+ } ) ,
394
+ ( "pkh" , 1 ) => expression :: terminal ( & top . args [ 0 ] , |pk| {
395
+ MiniscriptKey :: from_str ( pk, false ) . map ( Descriptor :: Pkh )
396
+ } ) ,
397
+ ( "wpkh" , 1 ) => expression :: terminal ( & top . args [ 0 ] , |pk| {
398
+ MiniscriptKey :: from_str ( pk, true ) . map ( Descriptor :: Wpkh )
399
+ } ) ,
400
400
( "sh" , 1 ) => {
401
401
let newtop = & top. args [ 0 ] ;
402
402
match ( newtop. name , newtop. args . len ( ) ) {
@@ -405,7 +405,7 @@ where
405
405
Ok ( Descriptor :: ShWsh ( sub) )
406
406
}
407
407
( "wpkh" , 1 ) => expression:: terminal ( & newtop. args [ 0 ] , |pk| {
408
- Pk :: from_str ( pk) . map ( Descriptor :: ShWpkh )
408
+ str :: FromStr :: from_str ( pk) . map ( Descriptor :: ShWpkh )
409
409
} ) ,
410
410
_ => {
411
411
let sub = Miniscript :: from_tree ( & top. args [ 0 ] ) ?;
@@ -618,6 +618,16 @@ mod tests {
618
618
"bc1qsn57m9drscflq5nl76z6ny52hck5w4x5wqd9yt"
619
619
) ;
620
620
621
+ // Only compressed pubkeys are allowed in wpkh(KEY)
622
+ assert_eq ! (
623
+ StdDescriptor :: from_str(
624
+ "wpkh(\
625
+ 044f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa385b6b1b8ead809ca67454d9683fcf2ba03456d6fe2c4abe2b07f0fbdbb2f1c1\
626
+ )",
627
+ ) . unwrap_err( ) . to_string( ) ,
628
+ "unexpected «base58 error: Uncompressed pubkeys are not allowed»"
629
+ ) ;
630
+
621
631
let shwpkh = StdDescriptor :: from_str (
622
632
"sh(wpkh(\
623
633
020000000000000000000000000000000000000000000000000000000000000002\
0 commit comments