@@ -13,7 +13,7 @@ use crate::{script_num_size, MiniscriptKey, Terminal};
13
13
14
14
/// Helper struct Whether any satisfaction of this fragment contains any timelocks
15
15
#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Debug , Default , Hash ) ]
16
- pub struct TimeLockInfo {
16
+ pub struct TimelockInfo {
17
17
/// csv with heights
18
18
pub csv_with_height : bool ,
19
19
/// csv with times
@@ -54,7 +54,7 @@ impl OpLimits {
54
54
}
55
55
}
56
56
57
- impl TimeLockInfo {
57
+ impl TimelockInfo {
58
58
/// Whether the current contains any possible unspendable
59
59
/// path
60
60
pub fn contains_unspendable_path ( self ) -> bool {
@@ -73,9 +73,9 @@ impl TimeLockInfo {
73
73
Self :: combine_threshold ( 1 , once ( a) . chain ( once ( b) ) )
74
74
}
75
75
76
- pub ( crate ) fn combine_threshold < I > ( k : usize , sub_timelocks : I ) -> TimeLockInfo
76
+ pub ( crate ) fn combine_threshold < I > ( k : usize , sub_timelocks : I ) -> TimelockInfo
77
77
where
78
- I : IntoIterator < Item = TimeLockInfo > ,
78
+ I : IntoIterator < Item = TimelockInfo > ,
79
79
{
80
80
// timelocks calculation
81
81
// Propagate all fields of `TimelockInfo` from each of the node's children to the node
@@ -86,7 +86,7 @@ impl TimeLockInfo {
86
86
// If `k > 1` we have the additional consideration that if any two children have conflicting
87
87
// timelock requirements, this represents an inaccessible spending branch.
88
88
sub_timelocks. into_iter ( ) . fold (
89
- TimeLockInfo :: default ( ) ,
89
+ TimelockInfo :: default ( ) ,
90
90
|mut timelock_info, sub_timelock| {
91
91
// If more than one branch may be taken, and some other branch has a requirement
92
92
// that conflicts with this one, set `contains_combination`
@@ -131,7 +131,7 @@ pub struct ExtData {
131
131
/// the cost for the witness stack, the second one is the cost for scriptSig.
132
132
pub max_dissat_size : Option < ( usize , usize ) > ,
133
133
/// The timelock info about heightlocks and timelocks
134
- pub timelock_info : TimeLockInfo ,
134
+ pub timelock_info : TimelockInfo ,
135
135
/// Maximum stack + alt stack size during satisfaction execution
136
136
/// This does **not** include initial witness elements. This element only captures
137
137
/// the additional elements that are pushed during execution.
@@ -163,7 +163,7 @@ impl Property for ExtData {
163
163
stack_elem_count_dissat : None ,
164
164
max_sat_size : Some ( ( 0 , 0 ) ) ,
165
165
max_dissat_size : None ,
166
- timelock_info : TimeLockInfo :: default ( ) ,
166
+ timelock_info : TimelockInfo :: default ( ) ,
167
167
exec_stack_elem_count_sat : Some ( 1 ) ,
168
168
exec_stack_elem_count_dissat : None ,
169
169
}
@@ -178,7 +178,7 @@ impl Property for ExtData {
178
178
stack_elem_count_dissat : Some ( 0 ) ,
179
179
max_sat_size : None ,
180
180
max_dissat_size : Some ( ( 0 , 0 ) ) ,
181
- timelock_info : TimeLockInfo :: default ( ) ,
181
+ timelock_info : TimelockInfo :: default ( ) ,
182
182
exec_stack_elem_count_sat : None ,
183
183
exec_stack_elem_count_dissat : Some ( 1 ) ,
184
184
}
@@ -199,7 +199,7 @@ impl Property for ExtData {
199
199
SigType :: Schnorr => Some ( ( 66 , 66 ) ) ,
200
200
} ,
201
201
max_dissat_size : Some ( ( 1 , 1 ) ) ,
202
- timelock_info : TimeLockInfo :: default ( ) ,
202
+ timelock_info : TimelockInfo :: default ( ) ,
203
203
exec_stack_elem_count_sat : Some ( 1 ) , // pushes the pk
204
204
exec_stack_elem_count_dissat : Some ( 1 ) ,
205
205
}
@@ -220,7 +220,7 @@ impl Property for ExtData {
220
220
SigType :: Ecdsa => Some ( ( 35 , 35 ) ) ,
221
221
SigType :: Schnorr => Some ( ( 34 , 34 ) ) ,
222
222
} ,
223
- timelock_info : TimeLockInfo :: default ( ) ,
223
+ timelock_info : TimelockInfo :: default ( ) ,
224
224
exec_stack_elem_count_sat : Some ( 2 ) , // dup and hash push
225
225
exec_stack_elem_count_dissat : Some ( 2 ) ,
226
226
}
@@ -243,7 +243,7 @@ impl Property for ExtData {
243
243
stack_elem_count_dissat : Some ( k + 1 ) ,
244
244
max_sat_size : Some ( ( 1 + 73 * k, 1 + 73 * k) ) ,
245
245
max_dissat_size : Some ( ( 1 + k, 1 + k) ) ,
246
- timelock_info : TimeLockInfo :: default ( ) ,
246
+ timelock_info : TimelockInfo :: default ( ) ,
247
247
exec_stack_elem_count_sat : Some ( n) , // n pks
248
248
exec_stack_elem_count_dissat : Some ( n) ,
249
249
}
@@ -265,7 +265,7 @@ impl Property for ExtData {
265
265
stack_elem_count_dissat : Some ( n) ,
266
266
max_sat_size : Some ( ( ( n - k) + 66 * k, ( n - k) + 66 * k) ) ,
267
267
max_dissat_size : Some ( ( n, n) ) ,
268
- timelock_info : TimeLockInfo :: default ( ) ,
268
+ timelock_info : TimelockInfo :: default ( ) ,
269
269
exec_stack_elem_count_sat : Some ( 2 ) , // the two nums before num equal verify
270
270
exec_stack_elem_count_dissat : Some ( 2 ) ,
271
271
}
@@ -285,7 +285,7 @@ impl Property for ExtData {
285
285
stack_elem_count_dissat : Some ( 1 ) ,
286
286
max_sat_size : Some ( ( 33 , 33 ) ) ,
287
287
max_dissat_size : Some ( ( 33 , 33 ) ) ,
288
- timelock_info : TimeLockInfo :: default ( ) ,
288
+ timelock_info : TimelockInfo :: default ( ) ,
289
289
exec_stack_elem_count_sat : Some ( 2 ) , // either size <32> or <hash256> <32 byte>
290
290
exec_stack_elem_count_dissat : Some ( 2 ) ,
291
291
}
@@ -300,7 +300,7 @@ impl Property for ExtData {
300
300
stack_elem_count_dissat : Some ( 1 ) ,
301
301
max_sat_size : Some ( ( 33 , 33 ) ) ,
302
302
max_dissat_size : Some ( ( 33 , 33 ) ) ,
303
- timelock_info : TimeLockInfo :: default ( ) ,
303
+ timelock_info : TimelockInfo :: default ( ) ,
304
304
exec_stack_elem_count_sat : Some ( 2 ) , // either size <32> or <hash256> <32 byte>
305
305
exec_stack_elem_count_dissat : Some ( 2 ) ,
306
306
}
@@ -315,7 +315,7 @@ impl Property for ExtData {
315
315
stack_elem_count_dissat : Some ( 1 ) ,
316
316
max_sat_size : Some ( ( 33 , 33 ) ) ,
317
317
max_dissat_size : Some ( ( 33 , 33 ) ) ,
318
- timelock_info : TimeLockInfo :: default ( ) ,
318
+ timelock_info : TimelockInfo :: default ( ) ,
319
319
exec_stack_elem_count_sat : Some ( 2 ) , // either size <32> or <hash256> <20 byte>
320
320
exec_stack_elem_count_dissat : Some ( 2 ) ,
321
321
}
@@ -330,7 +330,7 @@ impl Property for ExtData {
330
330
stack_elem_count_dissat : Some ( 1 ) ,
331
331
max_sat_size : Some ( ( 33 , 33 ) ) ,
332
332
max_dissat_size : Some ( ( 33 , 33 ) ) ,
333
- timelock_info : TimeLockInfo :: default ( ) ,
333
+ timelock_info : TimelockInfo :: default ( ) ,
334
334
exec_stack_elem_count_sat : Some ( 2 ) , // either size <32> or <hash256> <20 byte>
335
335
exec_stack_elem_count_dissat : Some ( 2 ) ,
336
336
}
@@ -349,7 +349,7 @@ impl Property for ExtData {
349
349
stack_elem_count_dissat : None ,
350
350
max_sat_size : Some ( ( 0 , 0 ) ) ,
351
351
max_dissat_size : None ,
352
- timelock_info : TimeLockInfo {
352
+ timelock_info : TimelockInfo {
353
353
csv_with_height : false ,
354
354
csv_with_time : false ,
355
355
cltv_with_height : t < LOCKTIME_THRESHOLD ,
@@ -370,7 +370,7 @@ impl Property for ExtData {
370
370
stack_elem_count_dissat : None ,
371
371
max_sat_size : Some ( ( 0 , 0 ) ) ,
372
372
max_dissat_size : None ,
373
- timelock_info : TimeLockInfo {
373
+ timelock_info : TimelockInfo {
374
374
csv_with_height : ( t & SEQUENCE_LOCKTIME_TYPE_FLAG ) == 0 ,
375
375
csv_with_time : ( t & SEQUENCE_LOCKTIME_TYPE_FLAG ) != 0 ,
376
376
cltv_with_height : false ,
@@ -518,7 +518,7 @@ impl Property for ExtData {
518
518
max_dissat_size : l
519
519
. max_dissat_size
520
520
. and_then ( |( lw, ls) | r. max_dissat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
521
- timelock_info : TimeLockInfo :: combine_and ( l. timelock_info , r. timelock_info ) ,
521
+ timelock_info : TimelockInfo :: combine_and ( l. timelock_info , r. timelock_info ) ,
522
522
// Left element leaves a stack result on the stack top and then right element is evaluated
523
523
// Therefore + 1 is added to execution size of second element
524
524
exec_stack_elem_count_sat : opt_max (
@@ -549,7 +549,7 @@ impl Property for ExtData {
549
549
. max_sat_size
550
550
. and_then ( |( lw, ls) | r. max_sat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
551
551
max_dissat_size : None ,
552
- timelock_info : TimeLockInfo :: combine_and ( l. timelock_info , r. timelock_info ) ,
552
+ timelock_info : TimelockInfo :: combine_and ( l. timelock_info , r. timelock_info ) ,
553
553
// [X] leaves no element after evaluation, hence this is the max
554
554
exec_stack_elem_count_sat : opt_max (
555
555
l. exec_stack_elem_count_sat ,
@@ -589,7 +589,7 @@ impl Property for ExtData {
589
589
max_dissat_size : l
590
590
. max_dissat_size
591
591
. and_then ( |( lw, ls) | r. max_dissat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
592
- timelock_info : TimeLockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
592
+ timelock_info : TimelockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
593
593
exec_stack_elem_count_sat : cmp:: max (
594
594
opt_max (
595
595
l. exec_stack_elem_count_sat ,
@@ -632,7 +632,7 @@ impl Property for ExtData {
632
632
max_dissat_size : l
633
633
. max_dissat_size
634
634
. and_then ( |( lw, ls) | r. max_dissat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
635
- timelock_info : TimeLockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
635
+ timelock_info : TimelockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
636
636
exec_stack_elem_count_sat : cmp:: max (
637
637
l. exec_stack_elem_count_sat ,
638
638
opt_max ( r. exec_stack_elem_count_sat , l. exec_stack_elem_count_dissat ) ,
@@ -666,7 +666,7 @@ impl Property for ExtData {
666
666
. and_then ( |( lw, ls) | r. max_sat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
667
667
) ,
668
668
max_dissat_size : None ,
669
- timelock_info : TimeLockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
669
+ timelock_info : TimelockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
670
670
exec_stack_elem_count_sat : cmp:: max (
671
671
l. exec_stack_elem_count_sat ,
672
672
opt_max ( r. exec_stack_elem_count_sat , l. exec_stack_elem_count_dissat ) ,
@@ -709,7 +709,7 @@ impl Property for ExtData {
709
709
( Some ( l) , None ) => Some ( ( 2 + l. 0 , 1 + l. 1 ) ) ,
710
710
( None , None ) => None ,
711
711
} ,
712
- timelock_info : TimeLockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
712
+ timelock_info : TimelockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
713
713
// TODO: fix elem count dissat bug
714
714
exec_stack_elem_count_sat : cmp:: max (
715
715
l. exec_stack_elem_count_sat ,
@@ -752,8 +752,8 @@ impl Property for ExtData {
752
752
max_dissat_size : a
753
753
. max_dissat_size
754
754
. and_then ( |( wa, sa) | c. max_dissat_size . map ( |( wc, sc) | ( wa + wc, sa + sc) ) ) ,
755
- timelock_info : TimeLockInfo :: combine_or (
756
- TimeLockInfo :: combine_and ( a. timelock_info , b. timelock_info ) ,
755
+ timelock_info : TimelockInfo :: combine_or (
756
+ TimelockInfo :: combine_and ( a. timelock_info , b. timelock_info ) ,
757
757
c. timelock_info ,
758
758
) ,
759
759
exec_stack_elem_count_sat : cmp:: max (
@@ -884,7 +884,7 @@ impl Property for ExtData {
884
884
stack_elem_count_dissat,
885
885
max_sat_size,
886
886
max_dissat_size,
887
- timelock_info : TimeLockInfo :: combine_threshold ( k, timelocks) ,
887
+ timelock_info : TimelockInfo :: combine_threshold ( k, timelocks) ,
888
888
exec_stack_elem_count_sat,
889
889
exec_stack_elem_count_dissat,
890
890
} )
0 commit comments