@@ -336,7 +336,7 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
336
336
) -> Result < Descriptor < Q > , E >
337
337
where
338
338
Fpk : FnMut ( & Pk ) -> Result < Q , E > ,
339
- Fpkh : FnMut ( & Pk :: Hash ) -> Result < Q :: Hash , E > ,
339
+ Fpkh : FnMut ( & Option < Pk > , & Pk :: Hash ) -> Result < ( Option < Q > , Q :: Hash ) , E > ,
340
340
Q : MiniscriptKey ,
341
341
{
342
342
match * self {
@@ -684,8 +684,11 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
684
684
}
685
685
686
686
impl Descriptor < DescriptorPublicKey > {
687
- /// Derives all wildcard keys in the descriptor using the supplied `child_number`
688
- pub fn derive ( & self , child_number : bip32:: ChildNumber ) -> Descriptor < DescriptorPublicKey > {
687
+ /// Derives all wildcard keys in the descriptor using the supplied `path`
688
+ pub fn derive (
689
+ & self ,
690
+ child_number : bip32:: ChildNumber ,
691
+ ) -> Result < Descriptor < DescriptorPublicKey > , Error > {
689
692
self . translate_pk (
690
693
|pk| Result :: Ok :: < DescriptorPublicKey , ( ) > ( pk. clone ( ) . derive ( child_number) ) ,
691
694
|pk, _| match * pk {
@@ -700,7 +703,7 @@ impl Descriptor<DescriptorPublicKey> {
700
703
None => Err ( ( ) ) ,
701
704
} ,
702
705
)
703
- . expect ( "Translation fn can't fail." )
706
+ . map_err ( |_| Error :: BadDescriptor )
704
707
}
705
708
}
706
709
@@ -1522,8 +1525,9 @@ pk(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHW
1522
1525
pk(03f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8))";
1523
1526
let policy: policy:: concrete:: Policy < DescriptorPublicKey > = descriptor_str. parse ( ) . unwrap ( ) ;
1524
1527
let descriptor = Descriptor :: Sh ( policy. compile ( ) . unwrap ( ) ) ;
1525
- let derived_descriptor =
1526
- descriptor. derive ( bip32:: ChildNumber :: from_normal_idx ( 42 ) . unwrap ( ) ) ;
1528
+ let derived_descriptor = descriptor
1529
+ . derive ( bip32:: ChildNumber :: from_normal_idx ( 42 ) . unwrap ( ) )
1530
+ . expect ( "Deriving descriptor" ) ;
1527
1531
1528
1532
let res_descriptor_str = "thresh(2,\
1529
1533
pk([d34db33f/44'/0'/0']xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/1/42),\
0 commit comments