@@ -157,7 +157,7 @@ pub trait DescriptorTrait<Pk: MiniscriptKey> {
157157/// This will panic if translatefpk returns an uncompressed key when
158158/// converting to a Segwit descriptor. To prevent this panic, ensure
159159/// translatefpk returns an error in this case instead.
160- pub trait PkTranslate < P : MiniscriptKey , Q : MiniscriptKey > {
160+ pub trait TranslatePk < P : MiniscriptKey , Q : MiniscriptKey > {
161161 /// The associated output type. This must be Self<Q>
162162 type Output ;
163163
@@ -188,17 +188,17 @@ pub trait PkTranslate<P: MiniscriptKey, Q: MiniscriptKey> {
188188 }
189189}
190190
191- /// Variant of `PkTranslate ` where P and Q both have the same hash
191+ /// Variant of `TranslatePk ` where P and Q both have the same hash
192192/// type, and the hashes can be converted by just cloning them
193- pub trait PkTranslate1 < P : MiniscriptKey , Q : MiniscriptKey < Hash = P :: Hash > > :
194- PkTranslate < P , Q >
193+ pub trait TranslatePk1 < P : MiniscriptKey , Q : MiniscriptKey < Hash = P :: Hash > > :
194+ TranslatePk < P , Q >
195195{
196196 /// Translate a struct from one generic to another where the
197197 /// translation for Pk is provided by translatefpk
198198 fn translate_pk1 < Fpk , E > (
199199 & self ,
200200 translatefpk : Fpk ,
201- ) -> Result < <Self as PkTranslate < P , Q > >:: Output , E >
201+ ) -> Result < <Self as TranslatePk < P , Q > >:: Output , E >
202202 where
203203 Fpk : FnMut ( & P ) -> Result < Q , E > ,
204204 {
@@ -210,24 +210,24 @@ pub trait PkTranslate1<P: MiniscriptKey, Q: MiniscriptKey<Hash = P::Hash>>:
210210 fn translate_pk1_infallible < Fpk : FnMut ( & P ) -> Q > (
211211 & self ,
212212 translatefpk : Fpk ,
213- ) -> <Self as PkTranslate < P , Q > >:: Output {
213+ ) -> <Self as TranslatePk < P , Q > >:: Output {
214214 self . translate_pk_infallible ( translatefpk, P :: Hash :: clone)
215215 }
216216}
217- impl < P : MiniscriptKey , Q : MiniscriptKey < Hash = P :: Hash > , T : PkTranslate < P , Q > > PkTranslate1 < P , Q >
217+ impl < P : MiniscriptKey , Q : MiniscriptKey < Hash = P :: Hash > , T : TranslatePk < P , Q > > TranslatePk1 < P , Q >
218218 for T
219219{
220220}
221221
222- /// Variant of `PkTranslate ` where P's hash is P, so the hashes
222+ /// Variant of `TranslatePk ` where P's hash is P, so the hashes
223223/// can be converted by reusing the key-conversion function
224- pub trait PkTranslate2 < P : MiniscriptKey < Hash = P > , Q : MiniscriptKey > : PkTranslate < P , Q > {
224+ pub trait TranslatePk2 < P : MiniscriptKey < Hash = P > , Q : MiniscriptKey > : TranslatePk < P , Q > {
225225 /// Translate a struct from one generic to another where the
226226 /// translation for Pk is provided by translatefpk
227227 fn translate_pk2 < Fpk : Fn ( & P ) -> Result < Q , E > , E > (
228228 & self ,
229229 translatefpk : Fpk ,
230- ) -> Result < <Self as PkTranslate < P , Q > >:: Output , E > {
230+ ) -> Result < <Self as TranslatePk < P , Q > >:: Output , E > {
231231 self . translate_pk ( & translatefpk, |h| {
232232 translatefpk ( h) . map ( |q| q. to_pubkeyhash ( ) )
233233 } )
@@ -238,23 +238,23 @@ pub trait PkTranslate2<P: MiniscriptKey<Hash = P>, Q: MiniscriptKey>: PkTranslat
238238 fn translate_pk2_infallible < Fpk : Fn ( & P ) -> Q > (
239239 & self ,
240240 translatefpk : Fpk ,
241- ) -> <Self as PkTranslate < P , Q > >:: Output {
241+ ) -> <Self as TranslatePk < P , Q > >:: Output {
242242 self . translate_pk_infallible ( & translatefpk, |h| translatefpk ( h) . to_pubkeyhash ( ) )
243243 }
244244}
245- impl < P : MiniscriptKey < Hash = P > , Q : MiniscriptKey , T : PkTranslate < P , Q > > PkTranslate2 < P , Q > for T { }
245+ impl < P : MiniscriptKey < Hash = P > , Q : MiniscriptKey , T : TranslatePk < P , Q > > TranslatePk2 < P , Q > for T { }
246246
247- /// Variant of `PkTranslate ` where Q's hash is `hash160` so we can
247+ /// Variant of `TranslatePk ` where Q's hash is `hash160` so we can
248248/// derive hashes by calling `hash_to_hash160`
249- pub trait PkTranslate3 < P : MiniscriptKey + ToPublicKey , Q : MiniscriptKey < Hash = hash160:: Hash > > :
250- PkTranslate < P , Q >
249+ pub trait TranslatePk3 < P : MiniscriptKey + ToPublicKey , Q : MiniscriptKey < Hash = hash160:: Hash > > :
250+ TranslatePk < P , Q >
251251{
252252 /// Translate a struct from one generic to another where the
253253 /// translation for Pk is provided by translatefpk
254254 fn translate_pk3 < Fpk , E > (
255255 & self ,
256256 translatefpk : Fpk ,
257- ) -> Result < <Self as PkTranslate < P , Q > >:: Output , E >
257+ ) -> Result < <Self as TranslatePk < P , Q > >:: Output , E >
258258 where
259259 Fpk : FnMut ( & P ) -> Result < Q , E > ,
260260 {
@@ -266,19 +266,19 @@ pub trait PkTranslate3<P: MiniscriptKey + ToPublicKey, Q: MiniscriptKey<Hash = h
266266 fn translate_pk3_infallible < Fpk : FnMut ( & P ) -> Q > (
267267 & self ,
268268 translatefpk : Fpk ,
269- ) -> <Self as PkTranslate < P , Q > >:: Output {
269+ ) -> <Self as TranslatePk < P , Q > >:: Output {
270270 self . translate_pk_infallible ( translatefpk, P :: hash_to_hash160)
271271 }
272272}
273273impl <
274274 P : MiniscriptKey + ToPublicKey ,
275275 Q : MiniscriptKey < Hash = hash160:: Hash > ,
276- T : PkTranslate < P , Q > ,
277- > PkTranslate3 < P , Q > for T
276+ T : TranslatePk < P , Q > ,
277+ > TranslatePk3 < P , Q > for T
278278{
279279}
280280
281- // There are some additional convenience functions we could add to `PkTranslate `
281+ // There are some additional convenience functions we could add to `TranslatePk `
282282// for the common special cases where `P::Hash == Q::Hash`, or when `P == P::Hash`,
283283// but these are blocked on https://github.com/rust-lang/rust/issues/20041 which
284284// is unlikely to arrive in Rust very soon, as of Jan 2021. Should revisit this.
@@ -383,7 +383,7 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
383383 }
384384}
385385
386- impl < P : MiniscriptKey , Q : MiniscriptKey > PkTranslate < P , Q > for Descriptor < P > {
386+ impl < P : MiniscriptKey , Q : MiniscriptKey > TranslatePk < P , Q > for Descriptor < P > {
387387 type Output = Descriptor < Q > ;
388388 /// Convert a descriptor using abstract keys to one using specific keys
389389 /// This will panic if translatefpk returns an uncompressed key when
@@ -683,7 +683,7 @@ serde_string_impl_pk!(Descriptor, "a script descriptor");
683683#[ cfg( test) ]
684684mod tests {
685685 use super :: checksum:: desc_checksum;
686- use super :: { DescriptorTrait , PkTranslate2 } ;
686+ use super :: { DescriptorTrait , TranslatePk2 } ;
687687 use bitcoin:: blockdata:: opcodes:: all:: { OP_CLTV , OP_CSV } ;
688688 use bitcoin:: blockdata:: script:: Instruction ;
689689 use bitcoin:: blockdata:: { opcodes, script} ;
0 commit comments