@@ -755,7 +755,6 @@ impl<Pk: MiniscriptKey, T: Extension> ForEachKey<Pk> for Descriptor<Pk, T> {
755
755
fn for_each_key < ' a , F : FnMut ( & ' a Pk ) -> bool > ( & ' a self , pred : F ) -> bool
756
756
where
757
757
Pk : ' a ,
758
- Pk :: RawPkHash : ' a ,
759
758
{
760
759
match * self {
761
760
Descriptor :: Bare ( ref bare) => bare. for_each_key ( pred) ,
@@ -796,25 +795,7 @@ impl<Ext: Extension + ParseableExt> Descriptor<DescriptorPublicKey, Ext> {
796
795
Ok ( pk. clone ( ) . at_derivation_index ( self . 0 ) )
797
796
}
798
797
799
- fn pkh ( & mut self , pkh : & DescriptorPublicKey ) -> Result < DefiniteDescriptorKey , ( ) > {
800
- Ok ( pkh. clone ( ) . at_derivation_index ( self . 0 ) )
801
- }
802
-
803
- fn sha256 ( & mut self , sha256 : & sha256:: Hash ) -> Result < sha256:: Hash , ( ) > {
804
- Ok ( * sha256)
805
- }
806
-
807
- fn hash256 ( & mut self , hash256 : & hash256:: Hash ) -> Result < hash256:: Hash , ( ) > {
808
- Ok ( * hash256)
809
- }
810
-
811
- fn ripemd160 ( & mut self , ripemd160 : & ripemd160:: Hash ) -> Result < ripemd160:: Hash , ( ) > {
812
- Ok ( * ripemd160)
813
- }
814
-
815
- fn hash160 ( & mut self , hash160 : & hash160:: Hash ) -> Result < hash160:: Hash , ( ) > {
816
- Ok ( * hash160)
817
- }
798
+ translate_hash_clone ! ( DescriptorPublicKey , DescriptorPublicKey , ( ) ) ;
818
799
}
819
800
self . translate_pk ( & mut Derivator ( index) )
820
801
. expect ( "BIP 32 key index substitution cannot fail" )
@@ -904,10 +885,6 @@ impl<Ext: Extension + ParseableExt> Descriptor<DescriptorPublicKey, Ext> {
904
885
parse_key ( pk, & mut self . 0 , self . 1 )
905
886
}
906
887
907
- fn pkh ( & mut self , pkh : & String ) -> Result < DescriptorPublicKey , Error > {
908
- parse_key ( pkh, & mut self . 0 , self . 1 )
909
- }
910
-
911
888
fn sha256 ( & mut self , sha256 : & String ) -> Result < sha256:: Hash , Error > {
912
889
let hash =
913
890
sha256:: Hash :: from_str ( sha256) . map_err ( |e| Error :: Unexpected ( e. to_string ( ) ) ) ?;
@@ -950,10 +927,6 @@ impl<Ext: Extension + ParseableExt> Descriptor<DescriptorPublicKey, Ext> {
950
927
key_to_string ( pk, self . 0 )
951
928
}
952
929
953
- fn pkh ( & mut self , pkh : & DescriptorPublicKey ) -> Result < String , ( ) > {
954
- key_to_string ( pkh, self . 0 )
955
- }
956
-
957
930
fn sha256 ( & mut self , sha256 : & sha256:: Hash ) -> Result < String , ( ) > {
958
931
Ok ( sha256. to_string ( ) )
959
932
}
@@ -1054,37 +1027,7 @@ impl<Ext: Extension> Descriptor<DefiniteDescriptorKey, Ext> {
1054
1027
pk. derive_public_key ( & self . 0 )
1055
1028
}
1056
1029
1057
- fn pkh (
1058
- & mut self ,
1059
- pkh : & DefiniteDescriptorKey ,
1060
- ) -> Result < bitcoin:: hashes:: hash160:: Hash , ConversionError > {
1061
- Ok ( pkh. derive_public_key ( & self . 0 ) ?. to_pubkeyhash ( ) )
1062
- }
1063
-
1064
- fn sha256 ( & mut self , sha256 : & sha256:: Hash ) -> Result < sha256:: Hash , ConversionError > {
1065
- Ok ( * sha256)
1066
- }
1067
-
1068
- fn hash256 (
1069
- & mut self ,
1070
- hash256 : & hash256:: Hash ,
1071
- ) -> Result < hash256:: Hash , ConversionError > {
1072
- Ok ( * hash256)
1073
- }
1074
-
1075
- fn ripemd160 (
1076
- & mut self ,
1077
- ripemd160 : & ripemd160:: Hash ,
1078
- ) -> Result < ripemd160:: Hash , ConversionError > {
1079
- Ok ( * ripemd160)
1080
- }
1081
-
1082
- fn hash160 (
1083
- & mut self ,
1084
- hash160 : & hash160:: Hash ,
1085
- ) -> Result < hash160:: Hash , ConversionError > {
1086
- Ok ( * hash160)
1087
- }
1030
+ translate_hash_clone ! ( DefiniteDescriptorKey , bitcoin:: PublicKey , ConversionError ) ;
1088
1031
}
1089
1032
1090
1033
let derived = self . translate_pk ( & mut Derivator ( secp) ) ?;
@@ -1195,7 +1138,7 @@ mod tests {
1195
1138
use crate :: miniscript:: satisfy:: ElementsSig ;
1196
1139
#[ cfg( feature = "compiler" ) ]
1197
1140
use crate :: policy;
1198
- use crate :: { hex_script, Descriptor , DummyKey , Error , Miniscript , Satisfier } ;
1141
+ use crate :: { hex_script, Descriptor , DummyKey , Error , Miniscript , NoExt , Satisfier } ;
1199
1142
1200
1143
type StdDescriptor = Descriptor < PublicKey , CovenantExt < CovExtArgs > > ;
1201
1144
const TEST_PK : & ' static str =
@@ -1667,8 +1610,8 @@ mod tests {
1667
1610
assert_eq ! (
1668
1611
descriptor,
1669
1612
format!(
1670
- "eltr({},{{pk({}),{{pk({}),or_d(pk({}),pkh(516ca378e588a7ed71336147e2a72848b20aca1a ))}}}})#3cw4zduf " ,
1671
- p1, p2, p3, p4,
1613
+ "eltr({},{{pk({}),{{pk({}),or_d(pk({}),pkh({} ))}}}})#y9kzzx3w " ,
1614
+ p1, p2, p3, p4, p5
1672
1615
)
1673
1616
)
1674
1617
}
0 commit comments