@@ -157,7 +157,7 @@ pub trait DescriptorTrait<Pk: MiniscriptKey> {
157
157
/// This will panic if translatefpk returns an uncompressed key when
158
158
/// converting to a Segwit descriptor. To prevent this panic, ensure
159
159
/// translatefpk returns an error in this case instead.
160
- pub trait PkTranslate < P : MiniscriptKey , Q : MiniscriptKey > {
160
+ pub trait TranslatePk < P : MiniscriptKey , Q : MiniscriptKey > {
161
161
/// The associated output type. This must be Self<Q>
162
162
type Output ;
163
163
@@ -188,17 +188,17 @@ pub trait PkTranslate<P: MiniscriptKey, Q: MiniscriptKey> {
188
188
}
189
189
}
190
190
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
192
192
/// 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 >
195
195
{
196
196
/// Translate a struct from one generic to another where the
197
197
/// translation for Pk is provided by translatefpk
198
198
fn translate_pk1 < Fpk , E > (
199
199
& self ,
200
200
translatefpk : Fpk ,
201
- ) -> Result < <Self as PkTranslate < P , Q > >:: Output , E >
201
+ ) -> Result < <Self as TranslatePk < P , Q > >:: Output , E >
202
202
where
203
203
Fpk : FnMut ( & P ) -> Result < Q , E > ,
204
204
{
@@ -210,24 +210,24 @@ pub trait PkTranslate1<P: MiniscriptKey, Q: MiniscriptKey<Hash = P::Hash>>:
210
210
fn translate_pk1_infallible < Fpk : FnMut ( & P ) -> Q > (
211
211
& self ,
212
212
translatefpk : Fpk ,
213
- ) -> <Self as PkTranslate < P , Q > >:: Output {
213
+ ) -> <Self as TranslatePk < P , Q > >:: Output {
214
214
self . translate_pk_infallible ( translatefpk, P :: Hash :: clone)
215
215
}
216
216
}
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 >
218
218
for T
219
219
{
220
220
}
221
221
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
223
223
/// 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 > {
225
225
/// Translate a struct from one generic to another where the
226
226
/// translation for Pk is provided by translatefpk
227
227
fn translate_pk2 < Fpk : Fn ( & P ) -> Result < Q , E > , E > (
228
228
& self ,
229
229
translatefpk : Fpk ,
230
- ) -> Result < <Self as PkTranslate < P , Q > >:: Output , E > {
230
+ ) -> Result < <Self as TranslatePk < P , Q > >:: Output , E > {
231
231
self . translate_pk ( & translatefpk, |h| {
232
232
translatefpk ( h) . map ( |q| q. to_pubkeyhash ( ) )
233
233
} )
@@ -238,23 +238,23 @@ pub trait PkTranslate2<P: MiniscriptKey<Hash = P>, Q: MiniscriptKey>: PkTranslat
238
238
fn translate_pk2_infallible < Fpk : Fn ( & P ) -> Q > (
239
239
& self ,
240
240
translatefpk : Fpk ,
241
- ) -> <Self as PkTranslate < P , Q > >:: Output {
241
+ ) -> <Self as TranslatePk < P , Q > >:: Output {
242
242
self . translate_pk_infallible ( & translatefpk, |h| translatefpk ( h) . to_pubkeyhash ( ) )
243
243
}
244
244
}
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 { }
246
246
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
248
248
/// 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 >
251
251
{
252
252
/// Translate a struct from one generic to another where the
253
253
/// translation for Pk is provided by translatefpk
254
254
fn translate_pk3 < Fpk , E > (
255
255
& self ,
256
256
translatefpk : Fpk ,
257
- ) -> Result < <Self as PkTranslate < P , Q > >:: Output , E >
257
+ ) -> Result < <Self as TranslatePk < P , Q > >:: Output , E >
258
258
where
259
259
Fpk : FnMut ( & P ) -> Result < Q , E > ,
260
260
{
@@ -266,19 +266,19 @@ pub trait PkTranslate3<P: MiniscriptKey + ToPublicKey, Q: MiniscriptKey<Hash = h
266
266
fn translate_pk3_infallible < Fpk : FnMut ( & P ) -> Q > (
267
267
& self ,
268
268
translatefpk : Fpk ,
269
- ) -> <Self as PkTranslate < P , Q > >:: Output {
269
+ ) -> <Self as TranslatePk < P , Q > >:: Output {
270
270
self . translate_pk_infallible ( translatefpk, P :: hash_to_hash160)
271
271
}
272
272
}
273
273
impl <
274
274
P : MiniscriptKey + ToPublicKey ,
275
275
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
278
278
{
279
279
}
280
280
281
- // There are some additional convenience functions we could add to `PkTranslate `
281
+ // There are some additional convenience functions we could add to `TranslatePk `
282
282
// for the common special cases where `P::Hash == Q::Hash`, or when `P == P::Hash`,
283
283
// but these are blocked on https://github.com/rust-lang/rust/issues/20041 which
284
284
// is unlikely to arrive in Rust very soon, as of Jan 2021. Should revisit this.
@@ -383,7 +383,7 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
383
383
}
384
384
}
385
385
386
- impl < P : MiniscriptKey , Q : MiniscriptKey > PkTranslate < P , Q > for Descriptor < P > {
386
+ impl < P : MiniscriptKey , Q : MiniscriptKey > TranslatePk < P , Q > for Descriptor < P > {
387
387
type Output = Descriptor < Q > ;
388
388
/// Convert a descriptor using abstract keys to one using specific keys
389
389
/// This will panic if translatefpk returns an uncompressed key when
@@ -683,7 +683,7 @@ serde_string_impl_pk!(Descriptor, "a script descriptor");
683
683
#[ cfg( test) ]
684
684
mod tests {
685
685
use super :: checksum:: desc_checksum;
686
- use super :: { DescriptorTrait , PkTranslate2 } ;
686
+ use super :: { DescriptorTrait , TranslatePk2 } ;
687
687
use bitcoin:: blockdata:: opcodes:: all:: { OP_CLTV , OP_CSV } ;
688
688
use bitcoin:: blockdata:: script:: Instruction ;
689
689
use bitcoin:: blockdata:: { opcodes, script} ;
0 commit comments