@@ -755,7 +755,6 @@ impl<Pk: MiniscriptKey, T: Extension> ForEachKey<Pk> for Descriptor<Pk, T> {
755755 fn for_each_key < ' a , F : FnMut ( & ' a Pk ) -> bool > ( & ' a self , pred : F ) -> bool
756756 where
757757 Pk : ' a ,
758- Pk :: RawPkHash : ' a ,
759758 {
760759 match * self {
761760 Descriptor :: Bare ( ref bare) => bare. for_each_key ( pred) ,
@@ -796,25 +795,7 @@ impl<Ext: Extension + ParseableExt> Descriptor<DescriptorPublicKey, Ext> {
796795 Ok ( pk. clone ( ) . at_derivation_index ( self . 0 ) )
797796 }
798797
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 , ( ) ) ;
818799 }
819800 self . translate_pk ( & mut Derivator ( index) )
820801 . expect ( "BIP 32 key index substitution cannot fail" )
@@ -904,10 +885,6 @@ impl<Ext: Extension + ParseableExt> Descriptor<DescriptorPublicKey, Ext> {
904885 parse_key ( pk, & mut self . 0 , self . 1 )
905886 }
906887
907- fn pkh ( & mut self , pkh : & String ) -> Result < DescriptorPublicKey , Error > {
908- parse_key ( pkh, & mut self . 0 , self . 1 )
909- }
910-
911888 fn sha256 ( & mut self , sha256 : & String ) -> Result < sha256:: Hash , Error > {
912889 let hash =
913890 sha256:: Hash :: from_str ( sha256) . map_err ( |e| Error :: Unexpected ( e. to_string ( ) ) ) ?;
@@ -950,10 +927,6 @@ impl<Ext: Extension + ParseableExt> Descriptor<DescriptorPublicKey, Ext> {
950927 key_to_string ( pk, self . 0 )
951928 }
952929
953- fn pkh ( & mut self , pkh : & DescriptorPublicKey ) -> Result < String , ( ) > {
954- key_to_string ( pkh, self . 0 )
955- }
956-
957930 fn sha256 ( & mut self , sha256 : & sha256:: Hash ) -> Result < String , ( ) > {
958931 Ok ( sha256. to_string ( ) )
959932 }
@@ -1054,37 +1027,7 @@ impl<Ext: Extension> Descriptor<DefiniteDescriptorKey, Ext> {
10541027 pk. derive_public_key ( & self . 0 )
10551028 }
10561029
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 ) ;
10881031 }
10891032
10901033 let derived = self . translate_pk ( & mut Derivator ( secp) ) ?;
@@ -1195,7 +1138,7 @@ mod tests {
11951138 use crate :: miniscript:: satisfy:: ElementsSig ;
11961139 #[ cfg( feature = "compiler" ) ]
11971140 use crate :: policy;
1198- use crate :: { hex_script, Descriptor , DummyKey , Error , Miniscript , Satisfier } ;
1141+ use crate :: { hex_script, Descriptor , DummyKey , Error , Miniscript , NoExt , Satisfier } ;
11991142
12001143 type StdDescriptor = Descriptor < PublicKey , CovenantExt < CovExtArgs > > ;
12011144 const TEST_PK : & ' static str =
@@ -1667,8 +1610,8 @@ mod tests {
16671610 assert_eq ! (
16681611 descriptor,
16691612 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
16721615 )
16731616 )
16741617 }
0 commit comments