@@ -153,8 +153,10 @@ pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Ha
153153 }
154154
155155 /// The associated PublicKey Hash for this [`MiniscriptKey`],
156- /// used in the pkh fragment
157- type Hash : Clone + Eq + Ord + fmt:: Display + fmt:: Debug + hash:: Hash ;
156+ /// used in the raw_pkh fragment
157+ /// This fragment is only internally used for representing partial descriptors when parsing from script
158+ /// The library does not support creating partial descriptors yet.
159+ type RawPkHash : Clone + Eq + Ord + fmt:: Display + fmt:: Debug + hash:: Hash ;
158160
159161 /// The associated [`sha256::Hash`] for this [`MiniscriptKey`],
160162 /// used in the hash256 fragment.
@@ -165,15 +167,15 @@ pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Ha
165167 type Hash256 : Clone + Eq + Ord + fmt:: Display + fmt:: Debug + hash:: Hash ;
166168
167169 /// Converts this key to the associated pubkey hash.
168- fn to_pubkeyhash ( & self ) -> Self :: Hash ;
170+ fn to_pubkeyhash ( & self ) -> Self :: RawPkHash ;
169171}
170172
171173impl MiniscriptKey for bitcoin:: secp256k1:: PublicKey {
172- type Hash = hash160:: Hash ;
174+ type RawPkHash = hash160:: Hash ;
173175 type Sha256 = sha256:: Hash ;
174176 type Hash256 = hash256:: Hash ;
175177
176- fn to_pubkeyhash ( & self ) -> Self :: Hash {
178+ fn to_pubkeyhash ( & self ) -> Self :: RawPkHash {
177179 hash160:: Hash :: hash ( & self . serialize ( ) )
178180 }
179181}
@@ -184,21 +186,21 @@ impl MiniscriptKey for bitcoin::PublicKey {
184186 !self . compressed
185187 }
186188
187- type Hash = hash160:: Hash ;
189+ type RawPkHash = hash160:: Hash ;
188190 type Sha256 = sha256:: Hash ;
189191 type Hash256 = hash256:: Hash ;
190192
191- fn to_pubkeyhash ( & self ) -> Self :: Hash {
193+ fn to_pubkeyhash ( & self ) -> Self :: RawPkHash {
192194 hash160:: Hash :: hash ( & self . to_bytes ( ) )
193195 }
194196}
195197
196198impl MiniscriptKey for bitcoin:: secp256k1:: XOnlyPublicKey {
197- type Hash = hash160:: Hash ;
199+ type RawPkHash = hash160:: Hash ;
198200 type Sha256 = sha256:: Hash ;
199201 type Hash256 = hash256:: Hash ;
200202
201- fn to_pubkeyhash ( & self ) -> Self :: Hash {
203+ fn to_pubkeyhash ( & self ) -> Self :: RawPkHash {
202204 hash160:: Hash :: hash ( & self . serialize ( ) )
203205 }
204206
@@ -208,11 +210,11 @@ impl MiniscriptKey for bitcoin::secp256k1::XOnlyPublicKey {
208210}
209211
210212impl MiniscriptKey for String {
211- type Hash = String ;
213+ type RawPkHash = String ;
212214 type Sha256 = String ; // specify hashes as string
213215 type Hash256 = String ;
214216
215- fn to_pubkeyhash ( & self ) -> Self :: Hash {
217+ fn to_pubkeyhash ( & self ) -> Self :: RawPkHash {
216218 ( & self ) . to_string ( )
217219 }
218220}
@@ -234,7 +236,7 @@ pub trait ToPublicKey: MiniscriptKey {
234236 /// that calling `MiniscriptKey::to_pubkeyhash` followed by this function
235237 /// should give the same result as calling `to_public_key` and hashing
236238 /// the result directly.
237- fn hash_to_hash160 ( hash : & <Self as MiniscriptKey >:: Hash ) -> hash160:: Hash ;
239+ fn hash_to_hash160 ( hash : & <Self as MiniscriptKey >:: RawPkHash ) -> hash160:: Hash ;
238240
239241 /// Converts the generic associated [`MiniscriptKey::Sha256`] to [`sha256::Hash`]
240242 fn to_sha256 ( hash : & <Self as MiniscriptKey >:: Sha256 ) -> sha256:: Hash ;
@@ -322,11 +324,11 @@ impl str::FromStr for DummyKey {
322324}
323325
324326impl MiniscriptKey for DummyKey {
325- type Hash = DummyKeyHash ;
327+ type RawPkHash = DummyKeyHash ;
326328 type Sha256 = DummySha256Hash ;
327329 type Hash256 = DummyHash256 ;
328330
329- fn to_pubkeyhash ( & self ) -> Self :: Hash {
331+ fn to_pubkeyhash ( & self ) -> Self :: RawPkHash {
330332 DummyKeyHash
331333 }
332334}
@@ -457,7 +459,7 @@ where
457459 fn pk ( & mut self , pk : & P ) -> Result < Q , E > ;
458460
459461 /// Translates public key hashes P::Hash -> Q::Hash.
460- fn pkh ( & mut self , pkh : & P :: Hash ) -> Result < Q :: Hash , E > ;
462+ fn pkh ( & mut self , pkh : & P :: RawPkHash ) -> Result < Q :: RawPkHash , E > ;
461463
462464 /// Provides the translation from P::Sha256 -> Q::Sha256
463465 fn sha256 ( & mut self , sha256 : & P :: Sha256 ) -> Result < Q :: Sha256 , E > ;
@@ -478,7 +480,7 @@ where
478480 fn pk ( & mut self , pk : & P ) -> Result < Q , E > ;
479481
480482 /// Provides the translation public keys hashes P::Hash -> Q::Hash
481- fn pkh ( & mut self , pkh : & P :: Hash ) -> Result < Q :: Hash , E > ;
483+ fn pkh ( & mut self , pkh : & P :: RawPkHash ) -> Result < Q :: RawPkHash , E > ;
482484}
483485
484486impl < P , Q , E , T > Translator < P , Q , E > for T
@@ -491,7 +493,10 @@ where
491493 <Self as PkTranslator < P , Q , E > >:: pk ( self , pk)
492494 }
493495
494- fn pkh ( & mut self , pkh : & <P as MiniscriptKey >:: Hash ) -> Result < <Q as MiniscriptKey >:: Hash , E > {
496+ fn pkh (
497+ & mut self ,
498+ pkh : & <P as MiniscriptKey >:: RawPkHash ,
499+ ) -> Result < <Q as MiniscriptKey >:: RawPkHash , E > {
495500 <Self as PkTranslator < P , Q , E > >:: pkh ( self , pkh)
496501 }
497502
@@ -538,14 +543,14 @@ pub trait ForEachKey<Pk: MiniscriptKey> {
538543 fn for_each_key < ' a , F : FnMut ( & ' a Pk ) -> bool > ( & ' a self , pred : F ) -> bool
539544 where
540545 Pk : ' a ,
541- Pk :: Hash : ' a ;
546+ Pk :: RawPkHash : ' a ;
542547
543548 /// Run a predicate on every key in the descriptor, returning whether
544549 /// the predicate returned true for any key
545550 fn for_any_key < ' a , F : FnMut ( & ' a Pk ) -> bool > ( & ' a self , mut pred : F ) -> bool
546551 where
547552 Pk : ' a ,
548- Pk :: Hash : ' a ,
553+ Pk :: RawPkHash : ' a ,
549554 {
550555 !self . for_each_key ( |key| !pred ( key) )
551556 }
0 commit comments