@@ -14,24 +14,24 @@ use bitcoin::{Address, Network, ScriptBuf};
14
14
15
15
use super :: checksum:: { self , verify_checksum} ;
16
16
use crate :: expression:: { self , FromTree } ;
17
- use crate :: miniscript:: context:: { ScriptContext , ScriptContextError } ;
17
+ use crate :: miniscript:: context:: { Context , ContextError } ;
18
18
use crate :: policy:: { semantic, Liftable } ;
19
19
use crate :: prelude:: * ;
20
20
use crate :: util:: { varint_len, witness_to_scriptsig} ;
21
21
use crate :: {
22
- BareCtx , Error , ForEachKey , Miniscript , MiniscriptKey , Satisfier , ToPublicKey , TranslateErr ,
23
- TranslatePk , Translator ,
22
+ BareCtx , Error , ForEachKey , Key , Miniscript , Satisfier , ToPublicKey , TranslateErr , TranslatePk ,
23
+ Translator ,
24
24
} ;
25
25
26
26
/// Create a Bare Descriptor. That is descriptor that is
27
27
/// not wrapped in sh or wsh. This covers the Pk descriptor
28
28
#[ derive( Clone , Ord , PartialOrd , Eq , PartialEq , Hash ) ]
29
- pub struct Bare < Pk : MiniscriptKey > {
29
+ pub struct Bare < Pk : Key > {
30
30
/// underlying miniscript
31
31
ms : Miniscript < Pk , BareCtx > ,
32
32
}
33
33
34
- impl < Pk : MiniscriptKey > Bare < Pk > {
34
+ impl < Pk : Key > Bare < Pk > {
35
35
/// Create a new raw descriptor
36
36
pub fn new ( ms : Miniscript < Pk , BareCtx > ) -> Result < Self , Error > {
37
37
// do the top-level checks
@@ -91,7 +91,7 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
91
91
}
92
92
}
93
93
94
- impl < Pk : MiniscriptKey + ToPublicKey > Bare < Pk > {
94
+ impl < Pk : Key + ToPublicKey > Bare < Pk > {
95
95
/// Obtains the corresponding script pubkey for this descriptor.
96
96
pub fn script_pubkey ( & self ) -> ScriptBuf {
97
97
self . ms . encode ( )
@@ -134,13 +134,13 @@ impl<Pk: MiniscriptKey + ToPublicKey> Bare<Pk> {
134
134
}
135
135
}
136
136
137
- impl < Pk : MiniscriptKey > fmt:: Debug for Bare < Pk > {
137
+ impl < Pk : Key > fmt:: Debug for Bare < Pk > {
138
138
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
139
139
write ! ( f, "{:?}" , self . ms)
140
140
}
141
141
}
142
142
143
- impl < Pk : MiniscriptKey > fmt:: Display for Bare < Pk > {
143
+ impl < Pk : Key > fmt:: Display for Bare < Pk > {
144
144
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
145
145
use fmt:: Write ;
146
146
let mut wrapped_f = checksum:: Formatter :: new ( f) ;
@@ -149,7 +149,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Bare<Pk> {
149
149
}
150
150
}
151
151
152
- impl < Pk : MiniscriptKey > Liftable < Pk > for Bare < Pk > {
152
+ impl < Pk : Key > Liftable < Pk > for Bare < Pk > {
153
153
fn lift ( & self ) -> Result < semantic:: Policy < Pk > , Error > {
154
154
self . ms . lift ( )
155
155
}
@@ -174,16 +174,16 @@ impl_from_str!(
174
174
}
175
175
) ;
176
176
177
- impl < Pk : MiniscriptKey > ForEachKey < Pk > for Bare < Pk > {
177
+ impl < Pk : Key > ForEachKey < Pk > for Bare < Pk > {
178
178
fn for_each_key < ' a , F : FnMut ( & ' a Pk ) -> bool > ( & ' a self , pred : F ) -> bool {
179
179
self . ms . for_each_key ( pred)
180
180
}
181
181
}
182
182
183
183
impl < P , Q > TranslatePk < P , Q > for Bare < P >
184
184
where
185
- P : MiniscriptKey ,
186
- Q : MiniscriptKey ,
185
+ P : Key ,
186
+ Q : Key ,
187
187
{
188
188
type Output = Bare < Q > ;
189
189
@@ -197,14 +197,14 @@ where
197
197
198
198
/// A bare PkH descriptor at top level
199
199
#[ derive( Clone , Ord , PartialOrd , Eq , PartialEq , Hash ) ]
200
- pub struct Pkh < Pk : MiniscriptKey > {
200
+ pub struct Pkh < Pk : Key > {
201
201
/// underlying publickey
202
202
pk : Pk ,
203
203
}
204
204
205
- impl < Pk : MiniscriptKey > Pkh < Pk > {
205
+ impl < Pk : Key > Pkh < Pk > {
206
206
/// Create a new Pkh descriptor
207
- pub fn new ( pk : Pk ) -> Result < Self , ScriptContextError > {
207
+ pub fn new ( pk : Pk ) -> Result < Self , ContextError > {
208
208
// do the top-level checks
209
209
match BareCtx :: check_pk ( & pk) {
210
210
Ok ( ( ) ) => Ok ( Pkh { pk } ) ,
@@ -254,7 +254,7 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
254
254
}
255
255
}
256
256
257
- impl < Pk : MiniscriptKey + ToPublicKey > Pkh < Pk > {
257
+ impl < Pk : Key + ToPublicKey > Pkh < Pk > {
258
258
/// Obtains the corresponding script pubkey for this descriptor.
259
259
pub fn script_pubkey ( & self ) -> ScriptBuf {
260
260
// Fine to hard code the `Network` here because we immediately call
@@ -311,13 +311,13 @@ impl<Pk: MiniscriptKey + ToPublicKey> Pkh<Pk> {
311
311
}
312
312
}
313
313
314
- impl < Pk : MiniscriptKey > fmt:: Debug for Pkh < Pk > {
314
+ impl < Pk : Key > fmt:: Debug for Pkh < Pk > {
315
315
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
316
316
write ! ( f, "pkh({:?})" , self . pk)
317
317
}
318
318
}
319
319
320
- impl < Pk : MiniscriptKey > fmt:: Display for Pkh < Pk > {
320
+ impl < Pk : Key > fmt:: Display for Pkh < Pk > {
321
321
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
322
322
use fmt:: Write ;
323
323
let mut wrapped_f = checksum:: Formatter :: new ( f) ;
@@ -326,7 +326,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Pkh<Pk> {
326
326
}
327
327
}
328
328
329
- impl < Pk : MiniscriptKey > Liftable < Pk > for Pkh < Pk > {
329
+ impl < Pk : Key > Liftable < Pk > for Pkh < Pk > {
330
330
fn lift ( & self ) -> Result < semantic:: Policy < Pk > , Error > {
331
331
Ok ( semantic:: Policy :: Key ( self . pk . clone ( ) ) )
332
332
}
@@ -359,16 +359,16 @@ impl_from_str!(
359
359
}
360
360
) ;
361
361
362
- impl < Pk : MiniscriptKey > ForEachKey < Pk > for Pkh < Pk > {
362
+ impl < Pk : Key > ForEachKey < Pk > for Pkh < Pk > {
363
363
fn for_each_key < ' a , F : FnMut ( & ' a Pk ) -> bool > ( & ' a self , mut pred : F ) -> bool {
364
364
pred ( & self . pk )
365
365
}
366
366
}
367
367
368
368
impl < P , Q > TranslatePk < P , Q > for Pkh < P >
369
369
where
370
- P : MiniscriptKey ,
371
- Q : MiniscriptKey ,
370
+ P : Key ,
371
+ Q : Key ,
372
372
{
373
373
type Output = Pkh < Q > ;
374
374
0 commit comments