@@ -66,6 +66,8 @@ pub enum LiftError {
66
66
HeightTimelockCombination ,
67
67
/// Duplicate Public Keys
68
68
BranchExceedResourceLimits ,
69
+ /// Cannot lift raw descriptors
70
+ RawDescriptorLift ,
69
71
}
70
72
71
73
impl fmt:: Display for LiftError {
@@ -77,6 +79,7 @@ impl fmt::Display for LiftError {
77
79
LiftError :: BranchExceedResourceLimits => f. write_str (
78
80
"Cannot lift policies containing one branch that exceeds resource limits" ,
79
81
) ,
82
+ LiftError :: RawDescriptorLift => f. write_str ( "Cannot lift raw descriptors" ) ,
80
83
}
81
84
}
82
85
}
@@ -87,7 +90,7 @@ impl error::Error for LiftError {
87
90
use self :: LiftError :: * ;
88
91
89
92
match self {
90
- HeightTimelockCombination | BranchExceedResourceLimits => None ,
93
+ HeightTimelockCombination | BranchExceedResourceLimits | RawDescriptorLift => None ,
91
94
}
92
95
}
93
96
}
@@ -124,8 +127,10 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Liftable<Pk> for Miniscript<Pk, Ctx>
124
127
impl < Pk : MiniscriptKey , Ctx : ScriptContext > Liftable < Pk > for Terminal < Pk , Ctx > {
125
128
fn lift ( & self ) -> Result < Semantic < Pk > , Error > {
126
129
let ret = match * self {
127
- Terminal :: PkK ( ref pk) | Terminal :: PkH ( ref pk) => Semantic :: KeyHash ( pk. to_pubkeyhash ( ) ) ,
128
- Terminal :: RawPkH ( ref pkh) => Semantic :: KeyHash ( pkh. clone ( ) ) ,
130
+ Terminal :: PkK ( ref pk) | Terminal :: PkH ( ref pk) => Semantic :: Key ( pk. clone ( ) ) ,
131
+ Terminal :: RawPkH ( ref _pkh) => {
132
+ return Err ( Error :: LiftError ( LiftError :: RawDescriptorLift ) )
133
+ }
129
134
Terminal :: After ( t) => Semantic :: After ( t) ,
130
135
Terminal :: Older ( t) => Semantic :: Older ( t) ,
131
136
Terminal :: Sha256 ( ref h) => Semantic :: Sha256 ( h. clone ( ) ) ,
@@ -161,12 +166,9 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Liftable<Pk> for Terminal<Pk, Ctx> {
161
166
let semantic_subs: Result < _ , Error > = subs. iter ( ) . map ( |s| s. node . lift ( ) ) . collect ( ) ;
162
167
Semantic :: Threshold ( k, semantic_subs?)
163
168
}
164
- Terminal :: Multi ( k, ref keys) | Terminal :: MultiA ( k, ref keys) => Semantic :: Threshold (
165
- k,
166
- keys. iter ( )
167
- . map ( |k| Semantic :: KeyHash ( k. to_pubkeyhash ( ) ) )
168
- . collect ( ) ,
169
- ) ,
169
+ Terminal :: Multi ( k, ref keys) | Terminal :: MultiA ( k, ref keys) => {
170
+ Semantic :: Threshold ( k, keys. iter ( ) . map ( |k| Semantic :: Key ( k. clone ( ) ) ) . collect ( ) )
171
+ }
170
172
}
171
173
. normalized ( ) ;
172
174
Ok ( ret)
@@ -200,7 +202,7 @@ impl<Pk: MiniscriptKey> Liftable<Pk> for Concrete<Pk> {
200
202
let ret = match * self {
201
203
Concrete :: Unsatisfiable => Semantic :: Unsatisfiable ,
202
204
Concrete :: Trivial => Semantic :: Trivial ,
203
- Concrete :: Key ( ref pk) => Semantic :: KeyHash ( pk. to_pubkeyhash ( ) ) ,
205
+ Concrete :: Key ( ref pk) => Semantic :: Key ( pk. clone ( ) ) ,
204
206
Concrete :: After ( t) => Semantic :: After ( t) ,
205
207
Concrete :: Older ( t) => Semantic :: Older ( t) ,
206
208
Concrete :: Sha256 ( ref h) => Semantic :: Sha256 ( h. clone ( ) ) ,
@@ -281,9 +283,9 @@ mod tests {
281
283
concrete_policy_rtt ( "or(99@pk(),1@pk())" ) ;
282
284
concrete_policy_rtt ( "and(pk(),or(99@pk(),1@older(12960)))" ) ;
283
285
284
- semantic_policy_rtt ( "pkh ()" ) ;
285
- semantic_policy_rtt ( "or(pkh (),pkh ())" ) ;
286
- semantic_policy_rtt ( "and(pkh (),pkh ())" ) ;
286
+ semantic_policy_rtt ( "pk ()" ) ;
287
+ semantic_policy_rtt ( "or(pk (),pk ())" ) ;
288
+ semantic_policy_rtt ( "and(pk (),pk ())" ) ;
287
289
288
290
//fuzzer crashes
289
291
assert ! ( ConcretePol :: from_str( "thresh()" ) . is_err( ) ) ;
@@ -362,11 +364,11 @@ mod tests {
362
364
Semantic :: Threshold (
363
365
2 ,
364
366
vec![
365
- Semantic :: KeyHash ( key_a. pubkey_hash ( ) . as_hash ( ) ) ,
367
+ Semantic :: Key ( key_a) ,
366
368
Semantic :: Older ( Sequence :: from_height( 42 ) )
367
369
]
368
370
) ,
369
- Semantic :: KeyHash ( key_b. pubkey_hash ( ) . as_hash ( ) )
371
+ Semantic :: Key ( key_b)
370
372
]
371
373
) ,
372
374
ms_str. lift( ) . unwrap( )
0 commit comments