@@ -66,6 +66,8 @@ pub enum LiftError {
6666 HeightTimelockCombination ,
6767 /// Duplicate Public Keys
6868 BranchExceedResourceLimits ,
69+ /// Cannot lift raw descriptors
70+ RawDescriptorLift ,
6971}
7072
7173impl fmt:: Display for LiftError {
@@ -77,6 +79,7 @@ impl fmt::Display for LiftError {
7779 LiftError :: BranchExceedResourceLimits => f. write_str (
7880 "Cannot lift policies containing one branch that exceeds resource limits" ,
7981 ) ,
82+ LiftError :: RawDescriptorLift => f. write_str ( "Cannot lift raw descriptors" ) ,
8083 }
8184 }
8285}
@@ -87,7 +90,7 @@ impl error::Error for LiftError {
8790 use self :: LiftError :: * ;
8891
8992 match self {
90- HeightTimelockCombination | BranchExceedResourceLimits => None ,
93+ HeightTimelockCombination | BranchExceedResourceLimits | RawDescriptorLift => None ,
9194 }
9295 }
9396}
@@ -124,8 +127,10 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Liftable<Pk> for Miniscript<Pk, Ctx>
124127impl < Pk : MiniscriptKey , Ctx : ScriptContext > Liftable < Pk > for Terminal < Pk , Ctx > {
125128 fn lift ( & self ) -> Result < Semantic < Pk > , Error > {
126129 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+ }
129134 Terminal :: After ( t) => Semantic :: After ( t) ,
130135 Terminal :: Older ( t) => Semantic :: Older ( t) ,
131136 Terminal :: Sha256 ( ref h) => Semantic :: Sha256 ( h. clone ( ) ) ,
@@ -161,12 +166,9 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Liftable<Pk> for Terminal<Pk, Ctx> {
161166 let semantic_subs: Result < _ , Error > = subs. iter ( ) . map ( |s| s. node . lift ( ) ) . collect ( ) ;
162167 Semantic :: Threshold ( k, semantic_subs?)
163168 }
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+ }
170172 }
171173 . normalized ( ) ;
172174 Ok ( ret)
@@ -200,7 +202,7 @@ impl<Pk: MiniscriptKey> Liftable<Pk> for Concrete<Pk> {
200202 let ret = match * self {
201203 Concrete :: Unsatisfiable => Semantic :: Unsatisfiable ,
202204 Concrete :: Trivial => Semantic :: Trivial ,
203- Concrete :: Key ( ref pk) => Semantic :: KeyHash ( pk. to_pubkeyhash ( ) ) ,
205+ Concrete :: Key ( ref pk) => Semantic :: Key ( pk. clone ( ) ) ,
204206 Concrete :: After ( t) => Semantic :: After ( t) ,
205207 Concrete :: Older ( t) => Semantic :: Older ( t) ,
206208 Concrete :: Sha256 ( ref h) => Semantic :: Sha256 ( h. clone ( ) ) ,
@@ -281,9 +283,9 @@ mod tests {
281283 concrete_policy_rtt ( "or(99@pk(),1@pk())" ) ;
282284 concrete_policy_rtt ( "and(pk(),or(99@pk(),1@older(12960)))" ) ;
283285
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 ())" ) ;
287289
288290 //fuzzer crashes
289291 assert ! ( ConcretePol :: from_str( "thresh()" ) . is_err( ) ) ;
@@ -362,11 +364,11 @@ mod tests {
362364 Semantic :: Threshold (
363365 2 ,
364366 vec![
365- Semantic :: KeyHash ( key_a. pubkey_hash ( ) . as_hash ( ) ) ,
367+ Semantic :: Key ( key_a) ,
366368 Semantic :: Older ( Sequence :: from_height( 42 ) )
367369 ]
368370 ) ,
369- Semantic :: KeyHash ( key_b. pubkey_hash ( ) . as_hash ( ) )
371+ Semantic :: Key ( key_b)
370372 ]
371373 ) ,
372374 ms_str. lift( ) . unwrap( )
0 commit comments