@@ -27,7 +27,7 @@ use crate::miniscript::context::ScriptContext;
27
27
use crate :: policy:: { semantic, Liftable } ;
28
28
use crate :: util:: { varint_len, witness_to_scriptsig} ;
29
29
use crate :: {
30
- BareCtx , Error , ForEach , ForEachKey , Miniscript , MiniscriptKey , Satisfier , ToPublicKey ,
30
+ BareCtx , Error , ForEach , ForEachKey , Miniscript , Key , Satisfier , ToPublicKey ,
31
31
TranslatePk ,
32
32
} ;
33
33
@@ -39,12 +39,12 @@ use super::{
39
39
/// Create a Bare Descriptor. That is descriptor that is
40
40
/// not wrapped in sh or wsh. This covers the Pk descriptor
41
41
#[ derive( Clone , Ord , PartialOrd , Eq , PartialEq , Hash ) ]
42
- pub struct Bare < Pk : MiniscriptKey > {
42
+ pub struct Bare < Pk : Key > {
43
43
/// underlying miniscript
44
44
ms : Miniscript < Pk , BareCtx > ,
45
45
}
46
46
47
- impl < Pk : MiniscriptKey > Bare < Pk > {
47
+ impl < Pk : Key > Bare < Pk > {
48
48
/// Create a new raw descriptor
49
49
pub fn new ( ms : Miniscript < Pk , BareCtx > ) -> Result < Self , Error > {
50
50
// do the top-level checks
@@ -63,7 +63,7 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
63
63
}
64
64
}
65
65
66
- impl < Pk : MiniscriptKey + ToPublicKey > Bare < Pk > {
66
+ impl < Pk : Key + ToPublicKey > Bare < Pk > {
67
67
/// Obtain the corresponding script pubkey for this descriptor
68
68
/// Non failing verion of [`DescriptorTrait::script_pubkey`] for this descriptor
69
69
pub fn spk ( & self ) -> Script {
@@ -83,32 +83,32 @@ impl<Pk: MiniscriptKey + ToPublicKey> Bare<Pk> {
83
83
}
84
84
}
85
85
86
- impl < Pk : MiniscriptKey > fmt:: Debug for Bare < Pk > {
86
+ impl < Pk : Key > fmt:: Debug for Bare < Pk > {
87
87
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
88
88
write ! ( f, "{:?}" , self . ms)
89
89
}
90
90
}
91
91
92
- impl < Pk : MiniscriptKey > fmt:: Display for Bare < Pk > {
92
+ impl < Pk : Key > fmt:: Display for Bare < Pk > {
93
93
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
94
94
let desc = format ! ( "{}" , self . ms) ;
95
95
let checksum = desc_checksum ( & desc) . map_err ( |_| fmt:: Error ) ?;
96
96
write ! ( f, "{}#{}" , & desc, & checksum)
97
97
}
98
98
}
99
99
100
- impl < Pk : MiniscriptKey > Liftable < Pk > for Bare < Pk > {
100
+ impl < Pk : Key > Liftable < Pk > for Bare < Pk > {
101
101
fn lift ( & self ) -> Result < semantic:: Policy < Pk > , Error > {
102
102
self . ms . lift ( )
103
103
}
104
104
}
105
105
106
106
impl < Pk > FromTree for Bare < Pk >
107
107
where
108
- Pk : MiniscriptKey + FromStr ,
108
+ Pk : Key + FromStr ,
109
109
Pk :: Hash : FromStr ,
110
110
<Pk as FromStr >:: Err : ToString ,
111
- <<Pk as MiniscriptKey >:: Hash as FromStr >:: Err : ToString ,
111
+ <<Pk as Key >:: Hash as FromStr >:: Err : ToString ,
112
112
{
113
113
fn from_tree ( top : & expression:: Tree ) -> Result < Self , Error > {
114
114
let sub = Miniscript :: < Pk , BareCtx > :: from_tree ( & top) ?;
@@ -119,10 +119,10 @@ where
119
119
120
120
impl < Pk > FromStr for Bare < Pk >
121
121
where
122
- Pk : MiniscriptKey + FromStr ,
122
+ Pk : Key + FromStr ,
123
123
Pk :: Hash : FromStr ,
124
124
<Pk as FromStr >:: Err : ToString ,
125
- <<Pk as MiniscriptKey >:: Hash as FromStr >:: Err : ToString ,
125
+ <<Pk as Key >:: Hash as FromStr >:: Err : ToString ,
126
126
{
127
127
type Err = Error ;
128
128
@@ -133,7 +133,7 @@ where
133
133
}
134
134
}
135
135
136
- impl < Pk : MiniscriptKey > DescriptorTrait < Pk > for Bare < Pk > {
136
+ impl < Pk : Key > DescriptorTrait < Pk > for Bare < Pk > {
137
137
fn sanity_check ( & self ) -> Result < ( ) , Error > {
138
138
self . ms . sanity_check ( ) ?;
139
139
Ok ( ( ) )
@@ -202,7 +202,7 @@ impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Bare<Pk> {
202
202
}
203
203
}
204
204
205
- impl < Pk : MiniscriptKey > ForEachKey < Pk > for Bare < Pk > {
205
+ impl < Pk : Key > ForEachKey < Pk > for Bare < Pk > {
206
206
fn for_each_key < ' a , F : FnMut ( ForEach < ' a , Pk > ) -> bool > ( & ' a self , pred : F ) -> bool
207
207
where
208
208
Pk : ' a ,
@@ -212,7 +212,7 @@ impl<Pk: MiniscriptKey> ForEachKey<Pk> for Bare<Pk> {
212
212
}
213
213
}
214
214
215
- impl < P : MiniscriptKey , Q : MiniscriptKey > TranslatePk < P , Q > for Bare < P > {
215
+ impl < P : Key , Q : Key > TranslatePk < P , Q > for Bare < P > {
216
216
type Output = Bare < Q > ;
217
217
218
218
fn translate_pk < Fpk , Fpkh , E > (
@@ -223,7 +223,7 @@ impl<P: MiniscriptKey, Q: MiniscriptKey> TranslatePk<P, Q> for Bare<P> {
223
223
where
224
224
Fpk : FnMut ( & P ) -> Result < Q , E > ,
225
225
Fpkh : FnMut ( & P :: Hash ) -> Result < Q :: Hash , E > ,
226
- Q : MiniscriptKey ,
226
+ Q : Key ,
227
227
{
228
228
Ok ( Bare :: new (
229
229
self . ms
@@ -235,12 +235,12 @@ impl<P: MiniscriptKey, Q: MiniscriptKey> TranslatePk<P, Q> for Bare<P> {
235
235
236
236
/// A bare PkH descriptor at top level
237
237
#[ derive( Clone , Ord , PartialOrd , Eq , PartialEq , Hash ) ]
238
- pub struct Pkh < Pk : MiniscriptKey > {
238
+ pub struct Pkh < Pk : Key > {
239
239
/// underlying publickey
240
240
pk : Pk ,
241
241
}
242
242
243
- impl < Pk : MiniscriptKey > Pkh < Pk > {
243
+ impl < Pk : Key > Pkh < Pk > {
244
244
/// Create a new Pkh descriptor
245
245
pub fn new ( pk : Pk ) -> Self {
246
246
// do the top-level checks
@@ -258,7 +258,7 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
258
258
}
259
259
}
260
260
261
- impl < Pk : MiniscriptKey + ToPublicKey > Pkh < Pk > {
261
+ impl < Pk : Key + ToPublicKey > Pkh < Pk > {
262
262
/// Obtain the corresponding script pubkey for this descriptor
263
263
/// Non failing verion of [`DescriptorTrait::script_pubkey`] for this descriptor
264
264
pub fn spk ( & self ) -> Script {
@@ -285,32 +285,32 @@ impl<Pk: MiniscriptKey + ToPublicKey> Pkh<Pk> {
285
285
}
286
286
}
287
287
288
- impl < Pk : MiniscriptKey > fmt:: Debug for Pkh < Pk > {
288
+ impl < Pk : Key > fmt:: Debug for Pkh < Pk > {
289
289
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
290
290
write ! ( f, "pkh({:?})" , self . pk)
291
291
}
292
292
}
293
293
294
- impl < Pk : MiniscriptKey > fmt:: Display for Pkh < Pk > {
294
+ impl < Pk : Key > fmt:: Display for Pkh < Pk > {
295
295
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
296
296
let desc = format ! ( "pkh({})" , self . pk) ;
297
297
let checksum = desc_checksum ( & desc) . map_err ( |_| fmt:: Error ) ?;
298
298
write ! ( f, "{}#{}" , & desc, & checksum)
299
299
}
300
300
}
301
301
302
- impl < Pk : MiniscriptKey > Liftable < Pk > for Pkh < Pk > {
302
+ impl < Pk : Key > Liftable < Pk > for Pkh < Pk > {
303
303
fn lift ( & self ) -> Result < semantic:: Policy < Pk > , Error > {
304
304
Ok ( semantic:: Policy :: KeyHash ( self . pk . to_pubkeyhash ( ) ) )
305
305
}
306
306
}
307
307
308
308
impl < Pk > FromTree for Pkh < Pk >
309
309
where
310
- Pk : MiniscriptKey + FromStr ,
310
+ Pk : Key + FromStr ,
311
311
Pk :: Hash : FromStr ,
312
312
<Pk as FromStr >:: Err : ToString ,
313
- <<Pk as MiniscriptKey >:: Hash as FromStr >:: Err : ToString ,
313
+ <<Pk as Key >:: Hash as FromStr >:: Err : ToString ,
314
314
{
315
315
fn from_tree ( top : & expression:: Tree ) -> Result < Self , Error > {
316
316
if top. name == "pkh" && top. args . len ( ) == 1 {
@@ -329,10 +329,10 @@ where
329
329
330
330
impl < Pk > FromStr for Pkh < Pk >
331
331
where
332
- Pk : MiniscriptKey + FromStr ,
332
+ Pk : Key + FromStr ,
333
333
Pk :: Hash : FromStr ,
334
334
<Pk as FromStr >:: Err : ToString ,
335
- <<Pk as MiniscriptKey >:: Hash as FromStr >:: Err : ToString ,
335
+ <<Pk as Key >:: Hash as FromStr >:: Err : ToString ,
336
336
{
337
337
type Err = Error ;
338
338
@@ -343,7 +343,7 @@ where
343
343
}
344
344
}
345
345
346
- impl < Pk : MiniscriptKey > DescriptorTrait < Pk > for Pkh < Pk > {
346
+ impl < Pk : Key > DescriptorTrait < Pk > for Pkh < Pk > {
347
347
fn sanity_check ( & self ) -> Result < ( ) , Error > {
348
348
Ok ( ( ) )
349
349
}
@@ -414,7 +414,7 @@ impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Pkh<Pk> {
414
414
}
415
415
}
416
416
417
- impl < Pk : MiniscriptKey > ForEachKey < Pk > for Pkh < Pk > {
417
+ impl < Pk : Key > ForEachKey < Pk > for Pkh < Pk > {
418
418
fn for_each_key < ' a , F : FnMut ( ForEach < ' a , Pk > ) -> bool > ( & ' a self , mut pred : F ) -> bool
419
419
where
420
420
Pk : ' a ,
@@ -424,7 +424,7 @@ impl<Pk: MiniscriptKey> ForEachKey<Pk> for Pkh<Pk> {
424
424
}
425
425
}
426
426
427
- impl < P : MiniscriptKey , Q : MiniscriptKey > TranslatePk < P , Q > for Pkh < P > {
427
+ impl < P : Key , Q : Key > TranslatePk < P , Q > for Pkh < P > {
428
428
type Output = Pkh < Q > ;
429
429
430
430
fn translate_pk < Fpk , Fpkh , E > (
@@ -435,7 +435,7 @@ impl<P: MiniscriptKey, Q: MiniscriptKey> TranslatePk<P, Q> for Pkh<P> {
435
435
where
436
436
Fpk : FnMut ( & P ) -> Result < Q , E > ,
437
437
Fpkh : FnMut ( & P :: Hash ) -> Result < Q :: Hash , E > ,
438
- Q : MiniscriptKey ,
438
+ Q : Key ,
439
439
{
440
440
Ok ( Pkh :: new ( translatefpk ( & self . pk ) ?) )
441
441
}
0 commit comments