@@ -328,7 +328,7 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
328
328
) -> Result < Descriptor < Q > , E >
329
329
where
330
330
Fpk : FnMut ( & Pk ) -> Result < Q , E > ,
331
- Fpkh : FnMut ( & Pk :: Hash ) -> Result < Q :: Hash , E > ,
331
+ Fpkh : FnMut ( & Option < Pk > , & Pk :: Hash ) -> Result < ( Option < Q > , Q :: Hash ) , E > ,
332
332
Q : MiniscriptKey ,
333
333
{
334
334
match * self {
@@ -676,8 +676,11 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
676
676
}
677
677
678
678
impl Descriptor < DescriptorPublicKey > {
679
- /// Derives all wildcard keys in the descriptor using the supplied `child_number`
680
- pub fn derive ( & self , child_number : bip32:: ChildNumber ) -> Descriptor < DescriptorPublicKey > {
679
+ /// Derives all wildcard keys in the descriptor using the supplied `path`
680
+ pub fn derive (
681
+ & self ,
682
+ child_number : bip32:: ChildNumber ,
683
+ ) -> Result < Descriptor < DescriptorPublicKey > , Error > {
681
684
self . translate_pk (
682
685
|pk| Result :: Ok :: < DescriptorPublicKey , ( ) > ( pk. clone ( ) . derive ( child_number) ) ,
683
686
|pk, _| match * pk {
@@ -692,7 +695,7 @@ impl Descriptor<DescriptorPublicKey> {
692
695
None => Err ( ( ) ) ,
693
696
} ,
694
697
)
695
- . expect ( "Translation fn can't fail." )
698
+ . map_err ( |_| Error :: BadDescriptor )
696
699
}
697
700
}
698
701
@@ -1514,8 +1517,9 @@ pk(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHW
1514
1517
pk(03f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8))";
1515
1518
let policy: policy:: concrete:: Policy < DescriptorPublicKey > = descriptor_str. parse ( ) . unwrap ( ) ;
1516
1519
let descriptor = Descriptor :: Sh ( policy. compile ( ) . unwrap ( ) ) ;
1517
- let derived_descriptor =
1518
- descriptor. derive ( bip32:: ChildNumber :: from_normal_idx ( 42 ) . unwrap ( ) ) ;
1520
+ let derived_descriptor = descriptor
1521
+ . derive ( bip32:: ChildNumber :: from_normal_idx ( 42 ) . unwrap ( ) )
1522
+ . expect ( "Deriving descriptor" ) ;
1519
1523
1520
1524
let res_descriptor_str = "thresh(2,\
1521
1525
pk([d34db33f/44'/0'/0']xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/1/42),\
0 commit comments