@@ -15,7 +15,7 @@ use std::error;
1515use crate :: descriptor:: Descriptor ;
1616use crate :: miniscript:: { Miniscript , ScriptContext } ;
1717use crate :: policy:: concrete:: Policy as Concrete ;
18- use crate :: policy:: r#abstract:: Policy as Semantic ;
18+ use crate :: policy:: r#abstract:: Policy as Abstract ;
1919use crate :: sync:: Arc ;
2020use crate :: { Error , MiniscriptKey , Terminal } ;
2121
@@ -24,7 +24,7 @@ use crate::{Error, MiniscriptKey, Terminal};
2424///
2525/// After Lifting all policies are converted into `KeyHash(Pk::HasH)` to
2626/// maintain the following invariant(modulo resource limits):
27- /// `Lift(Concrete) == Concrete -> Miniscript -> Script -> Miniscript -> Semantic `
27+ /// `Lift(Concrete) == Concrete -> Miniscript -> Script -> Miniscript -> Abstract `
2828///
2929/// Lifting from [`Miniscript`] or [`Descriptor`] can fail if the miniscript
3030/// contains a timelock combination or if it contains a branch that exceeds
@@ -37,7 +37,7 @@ use crate::{Error, MiniscriptKey, Terminal};
3737/// policies.
3838pub trait Liftable < Pk : MiniscriptKey > {
3939 /// Converts this object into an abstract policy.
40- fn lift ( & self ) -> Result < Semantic < Pk > , Error > ;
40+ fn lift ( & self ) -> Result < Abstract < Pk > , Error > ;
4141}
4242
4343/// Error occurring during lifting.
@@ -77,7 +77,7 @@ impl error::Error for LiftError {
7777}
7878
7979impl < Pk : MiniscriptKey , Ctx : ScriptContext > Miniscript < Pk , Ctx > {
80- /// Lifting corresponds to conversion of a miniscript into a [`Semantic `]
80+ /// Lifting corresponds to conversion of a miniscript into a [`Abstract `]
8181 /// policy for human readable or machine analysis. However, naively lifting
8282 /// miniscripts can result in incorrect interpretations that don't
8383 /// correspond to the underlying semantics when we try to spend them on
@@ -96,7 +96,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
9696}
9797
9898impl < Pk : MiniscriptKey , Ctx : ScriptContext > Liftable < Pk > for Miniscript < Pk , Ctx > {
99- fn lift ( & self ) -> Result < Semantic < Pk > , Error > {
99+ fn lift ( & self ) -> Result < Abstract < Pk > , Error > {
100100 // check whether the root miniscript can have a spending path that is
101101 // a combination of heightlock and timelock
102102 self . lift_check ( ) ?;
@@ -105,20 +105,20 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Liftable<Pk> for Miniscript<Pk, Ctx>
105105}
106106
107107impl < Pk : MiniscriptKey , Ctx : ScriptContext > Liftable < Pk > for Terminal < Pk , Ctx > {
108- fn lift ( & self ) -> Result < Semantic < Pk > , Error > {
108+ fn lift ( & self ) -> Result < Abstract < Pk > , Error > {
109109 let ret = match * self {
110- Terminal :: PkK ( ref pk) | Terminal :: PkH ( ref pk) => Semantic :: Key ( pk. clone ( ) ) ,
110+ Terminal :: PkK ( ref pk) | Terminal :: PkH ( ref pk) => Abstract :: Key ( pk. clone ( ) ) ,
111111 Terminal :: RawPkH ( ref _pkh) => {
112112 return Err ( Error :: LiftError ( LiftError :: RawDescriptorLift ) )
113113 }
114- Terminal :: After ( t) => Semantic :: After ( t) ,
115- Terminal :: Older ( t) => Semantic :: Older ( t) ,
116- Terminal :: Sha256 ( ref h) => Semantic :: Sha256 ( h. clone ( ) ) ,
117- Terminal :: Hash256 ( ref h) => Semantic :: Hash256 ( h. clone ( ) ) ,
118- Terminal :: Ripemd160 ( ref h) => Semantic :: Ripemd160 ( h. clone ( ) ) ,
119- Terminal :: Hash160 ( ref h) => Semantic :: Hash160 ( h. clone ( ) ) ,
120- Terminal :: False => Semantic :: Unsatisfiable ,
121- Terminal :: True => Semantic :: Trivial ,
114+ Terminal :: After ( t) => Abstract :: After ( t) ,
115+ Terminal :: Older ( t) => Abstract :: Older ( t) ,
116+ Terminal :: Sha256 ( ref h) => Abstract :: Sha256 ( h. clone ( ) ) ,
117+ Terminal :: Hash256 ( ref h) => Abstract :: Hash256 ( h. clone ( ) ) ,
118+ Terminal :: Ripemd160 ( ref h) => Abstract :: Ripemd160 ( h. clone ( ) ) ,
119+ Terminal :: Hash160 ( ref h) => Abstract :: Hash160 ( h. clone ( ) ) ,
120+ Terminal :: False => Abstract :: Unsatisfiable ,
121+ Terminal :: True => Abstract :: Trivial ,
122122 Terminal :: Alt ( ref sub)
123123 | Terminal :: Swap ( ref sub)
124124 | Terminal :: Check ( ref sub)
@@ -127,27 +127,27 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Liftable<Pk> for Terminal<Pk, Ctx> {
127127 | Terminal :: NonZero ( ref sub)
128128 | Terminal :: ZeroNotEqual ( ref sub) => sub. node . lift ( ) ?,
129129 Terminal :: AndV ( ref left, ref right) | Terminal :: AndB ( ref left, ref right) => {
130- Semantic :: Threshold ( 2 , vec ! [ left. node. lift( ) ?, right. node. lift( ) ?] )
130+ Abstract :: Threshold ( 2 , vec ! [ left. node. lift( ) ?, right. node. lift( ) ?] )
131131 }
132- Terminal :: AndOr ( ref a, ref b, ref c) => Semantic :: Threshold (
132+ Terminal :: AndOr ( ref a, ref b, ref c) => Abstract :: Threshold (
133133 1 ,
134134 vec ! [
135- Semantic :: Threshold ( 2 , vec![ a. node. lift( ) ?, b. node. lift( ) ?] ) ,
135+ Abstract :: Threshold ( 2 , vec![ a. node. lift( ) ?, b. node. lift( ) ?] ) ,
136136 c. node. lift( ) ?,
137137 ] ,
138138 ) ,
139139 Terminal :: OrB ( ref left, ref right)
140140 | Terminal :: OrD ( ref left, ref right)
141141 | Terminal :: OrC ( ref left, ref right)
142142 | Terminal :: OrI ( ref left, ref right) => {
143- Semantic :: Threshold ( 1 , vec ! [ left. node. lift( ) ?, right. node. lift( ) ?] )
143+ Abstract :: Threshold ( 1 , vec ! [ left. node. lift( ) ?, right. node. lift( ) ?] )
144144 }
145145 Terminal :: Thresh ( k, ref subs) => {
146146 let semantic_subs: Result < _ , Error > = subs. iter ( ) . map ( |s| s. node . lift ( ) ) . collect ( ) ;
147- Semantic :: Threshold ( k, semantic_subs?)
147+ Abstract :: Threshold ( k, semantic_subs?)
148148 }
149149 Terminal :: Multi ( k, ref keys) | Terminal :: MultiA ( k, ref keys) => {
150- Semantic :: Threshold ( k, keys. iter ( ) . map ( |k| Semantic :: Key ( k. clone ( ) ) ) . collect ( ) )
150+ Abstract :: Threshold ( k, keys. iter ( ) . map ( |k| Abstract :: Key ( k. clone ( ) ) ) . collect ( ) )
151151 }
152152 }
153153 . normalized ( ) ;
@@ -156,7 +156,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Liftable<Pk> for Terminal<Pk, Ctx> {
156156}
157157
158158impl < Pk : MiniscriptKey > Liftable < Pk > for Descriptor < Pk > {
159- fn lift ( & self ) -> Result < Semantic < Pk > , Error > {
159+ fn lift ( & self ) -> Result < Abstract < Pk > , Error > {
160160 match * self {
161161 Descriptor :: Bare ( ref bare) => bare. lift ( ) ,
162162 Descriptor :: Pkh ( ref pkh) => pkh. lift ( ) ,
@@ -168,45 +168,45 @@ impl<Pk: MiniscriptKey> Liftable<Pk> for Descriptor<Pk> {
168168 }
169169}
170170
171- impl < Pk : MiniscriptKey > Liftable < Pk > for Semantic < Pk > {
172- fn lift ( & self ) -> Result < Semantic < Pk > , Error > { Ok ( self . clone ( ) ) }
171+ impl < Pk : MiniscriptKey > Liftable < Pk > for Abstract < Pk > {
172+ fn lift ( & self ) -> Result < Abstract < Pk > , Error > { Ok ( self . clone ( ) ) }
173173}
174174
175175impl < Pk : MiniscriptKey > Liftable < Pk > for Concrete < Pk > {
176- fn lift ( & self ) -> Result < Semantic < Pk > , Error > {
176+ fn lift ( & self ) -> Result < Abstract < Pk > , Error > {
177177 // do not lift if there is a possible satisfaction
178178 // involving combination of timelocks and heightlocks
179179 self . check_timelocks ( ) ?;
180180 let ret = match * self {
181- Concrete :: Unsatisfiable => Semantic :: Unsatisfiable ,
182- Concrete :: Trivial => Semantic :: Trivial ,
183- Concrete :: Key ( ref pk) => Semantic :: Key ( pk. clone ( ) ) ,
184- Concrete :: After ( t) => Semantic :: After ( t) ,
185- Concrete :: Older ( t) => Semantic :: Older ( t) ,
186- Concrete :: Sha256 ( ref h) => Semantic :: Sha256 ( h. clone ( ) ) ,
187- Concrete :: Hash256 ( ref h) => Semantic :: Hash256 ( h. clone ( ) ) ,
188- Concrete :: Ripemd160 ( ref h) => Semantic :: Ripemd160 ( h. clone ( ) ) ,
189- Concrete :: Hash160 ( ref h) => Semantic :: Hash160 ( h. clone ( ) ) ,
181+ Concrete :: Unsatisfiable => Abstract :: Unsatisfiable ,
182+ Concrete :: Trivial => Abstract :: Trivial ,
183+ Concrete :: Key ( ref pk) => Abstract :: Key ( pk. clone ( ) ) ,
184+ Concrete :: After ( t) => Abstract :: After ( t) ,
185+ Concrete :: Older ( t) => Abstract :: Older ( t) ,
186+ Concrete :: Sha256 ( ref h) => Abstract :: Sha256 ( h. clone ( ) ) ,
187+ Concrete :: Hash256 ( ref h) => Abstract :: Hash256 ( h. clone ( ) ) ,
188+ Concrete :: Ripemd160 ( ref h) => Abstract :: Ripemd160 ( h. clone ( ) ) ,
189+ Concrete :: Hash160 ( ref h) => Abstract :: Hash160 ( h. clone ( ) ) ,
190190 Concrete :: And ( ref subs) => {
191191 let semantic_subs: Result < _ , Error > = subs. iter ( ) . map ( Liftable :: lift) . collect ( ) ;
192- Semantic :: Threshold ( 2 , semantic_subs?)
192+ Abstract :: Threshold ( 2 , semantic_subs?)
193193 }
194194 Concrete :: Or ( ref subs) => {
195195 let semantic_subs: Result < _ , Error > =
196196 subs. iter ( ) . map ( |( _p, sub) | sub. lift ( ) ) . collect ( ) ;
197- Semantic :: Threshold ( 1 , semantic_subs?)
197+ Abstract :: Threshold ( 1 , semantic_subs?)
198198 }
199199 Concrete :: Threshold ( k, ref subs) => {
200200 let semantic_subs: Result < _ , Error > = subs. iter ( ) . map ( Liftable :: lift) . collect ( ) ;
201- Semantic :: Threshold ( k, semantic_subs?)
201+ Abstract :: Threshold ( k, semantic_subs?)
202202 }
203203 }
204204 . normalized ( ) ;
205205 Ok ( ret)
206206 }
207207}
208208impl < Pk : MiniscriptKey > Liftable < Pk > for Arc < Concrete < Pk > > {
209- fn lift ( & self ) -> Result < Semantic < Pk > , Error > { self . as_ref ( ) . lift ( ) }
209+ fn lift ( & self ) -> Result < Abstract < Pk > , Error > { self . as_ref ( ) . lift ( ) }
210210}
211211
212212#[ cfg( test) ]
@@ -227,7 +227,7 @@ mod tests {
227227 use crate :: { descriptor:: TapTree , Descriptor , Tap } ;
228228
229229 type ConcretePol = crate :: policy:: concrete:: Policy < String > ;
230- type SemanticPol = crate :: policy:: r#abstract:: Policy < String > ;
230+ type AbstractPol = crate :: policy:: r#abstract:: Policy < String > ;
231231
232232 fn concrete_policy_rtt ( s : & str ) {
233233 let conc = ConcretePol :: from_str ( s) . unwrap ( ) ;
@@ -236,7 +236,7 @@ mod tests {
236236 }
237237
238238 fn semantic_policy_rtt ( s : & str ) {
239- let sem = SemanticPol :: from_str ( s) . unwrap ( ) ;
239+ let sem = AbstractPol :: from_str ( s) . unwrap ( ) ;
240240 let output = sem. normalized ( ) . to_string ( ) ;
241241 assert_eq ! ( s. to_lowercase( ) , output. to_lowercase( ) ) ;
242242 }
@@ -269,8 +269,8 @@ mod tests {
269269
270270 //fuzzer crashes
271271 assert ! ( ConcretePol :: from_str( "thresh()" ) . is_err( ) ) ;
272- assert ! ( SemanticPol :: from_str( "thresh(0)" ) . is_err( ) ) ;
273- assert ! ( SemanticPol :: from_str( "thresh()" ) . is_err( ) ) ;
272+ assert ! ( AbstractPol :: from_str( "thresh(0)" ) . is_err( ) ) ;
273+ assert ! ( AbstractPol :: from_str( "thresh()" ) . is_err( ) ) ;
274274 concrete_policy_rtt ( "ripemd160()" ) ;
275275 }
276276
@@ -336,17 +336,17 @@ mod tests {
336336 . parse ( )
337337 . unwrap ( ) ;
338338 assert_eq ! (
339- Semantic :: Threshold (
339+ Abstract :: Threshold (
340340 1 ,
341341 vec![
342- Semantic :: Threshold (
342+ Abstract :: Threshold (
343343 2 ,
344344 vec![
345- Semantic :: Key ( key_a) ,
346- Semantic :: Older ( Sequence :: from_height( 42 ) )
345+ Abstract :: Key ( key_a) ,
346+ Abstract :: Older ( Sequence :: from_height( 42 ) )
347347 ]
348348 ) ,
349- Semantic :: Key ( key_b)
349+ Abstract :: Key ( key_b)
350350 ]
351351 ) ,
352352 ms_str. lift( ) . unwrap( )
0 commit comments