@@ -18,7 +18,9 @@ use super::context::SigType;
18
18
use crate :: plan:: AssetProvider ;
19
19
use crate :: prelude:: * ;
20
20
use crate :: util:: witness_size;
21
- use crate :: { AbsLockTime , Miniscript , MiniscriptKey , ScriptContext , Terminal , ToPublicKey } ;
21
+ use crate :: {
22
+ AbsLockTime , Miniscript , MiniscriptKey , RelLockTime , ScriptContext , Terminal , ToPublicKey ,
23
+ } ;
22
24
23
25
/// Type alias for 32 byte Preimage.
24
26
pub type Preimage32 = [ u8 ; 32 ] ;
@@ -117,6 +119,12 @@ impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for Sequence {
117
119
}
118
120
}
119
121
122
+ impl < Pk : MiniscriptKey + ToPublicKey > Satisfier < Pk > for RelLockTime {
123
+ fn check_older ( & self , n : relative:: LockTime ) -> bool {
124
+ <relative:: LockTime as Satisfier < Pk > >:: check_older ( & ( * self ) . into ( ) , n)
125
+ }
126
+ }
127
+
120
128
impl < Pk : MiniscriptKey + ToPublicKey > Satisfier < Pk > for relative:: LockTime {
121
129
fn check_older ( & self , n : relative:: LockTime ) -> bool { n. is_implied_by ( * self ) }
122
130
}
@@ -876,7 +884,7 @@ pub struct Satisfaction<T> {
876
884
/// The absolute timelock used by this satisfaction
877
885
pub absolute_timelock : Option < AbsLockTime > ,
878
886
/// The relative timelock used by this satisfaction
879
- pub relative_timelock : Option < Sequence > ,
887
+ pub relative_timelock : Option < RelLockTime > ,
880
888
}
881
889
882
890
impl < Pk : MiniscriptKey + ToPublicKey > Satisfaction < Placeholder < Pk > > {
@@ -1278,19 +1286,19 @@ impl<Pk: MiniscriptKey + ToPublicKey> Satisfaction<Placeholder<Pk>> {
1278
1286
}
1279
1287
Terminal :: Older ( t) => {
1280
1288
// unwrap to be removed in a later commit
1281
- let ( stack , relative_timelock ) =
1282
- if stfr. check_older ( t. to_relative_lock_time ( ) . unwrap ( ) ) {
1283
- ( Witness :: empty ( ) , Some ( t) )
1284
- } else if root_has_sig {
1285
- // If the root terminal has signature, the
1286
- // signature covers the nLockTime and nSequence
1287
- // values. The sender of the transaction should
1288
- // take care that it signs the value such that the
1289
- // timelock is not met
1290
- ( Witness :: Impossible , None )
1291
- } else {
1292
- ( Witness :: Unavailable , None )
1293
- } ;
1289
+ let t = < RelLockTime as core :: convert :: TryFrom < _ > > :: try_from ( t ) . unwrap ( ) ;
1290
+ let ( stack , relative_timelock ) = if stfr. check_older ( t. into ( ) ) {
1291
+ ( Witness :: empty ( ) , Some ( t) )
1292
+ } else if root_has_sig {
1293
+ // If the root terminal has signature, the
1294
+ // signature covers the nLockTime and nSequence
1295
+ // values. The sender of the transaction should
1296
+ // take care that it signs the value such that the
1297
+ // timelock is not met
1298
+ ( Witness :: Impossible , None )
1299
+ } else {
1300
+ ( Witness :: Unavailable , None )
1301
+ } ;
1294
1302
Satisfaction { stack, has_sig : false , relative_timelock, absolute_timelock : None }
1295
1303
}
1296
1304
Terminal :: Ripemd160 ( ref h) => Satisfaction {
0 commit comments