@@ -12,7 +12,7 @@ use crate::{script_num_size, MiniscriptKey, Terminal};
12
12
13
13
/// Helper struct Whether any satisfaction of this fragment contains any timelocks
14
14
#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Debug , Default , Hash ) ]
15
- pub struct TimeLockInfo {
15
+ pub struct TimelockInfo {
16
16
/// csv with heights
17
17
pub ( crate ) csv_with_height : bool ,
18
18
/// csv with times
@@ -53,7 +53,7 @@ impl OpLimits {
53
53
}
54
54
}
55
55
56
- impl TimeLockInfo {
56
+ impl TimelockInfo {
57
57
/// Whether the current contains any possible unspendable
58
58
/// path
59
59
pub fn contains_unspendable_path ( self ) -> bool {
@@ -72,9 +72,9 @@ impl TimeLockInfo {
72
72
Self :: combine_threshold ( 1 , once ( a) . chain ( once ( b) ) )
73
73
}
74
74
75
- pub ( crate ) fn combine_threshold < I > ( k : usize , sub_timelocks : I ) -> TimeLockInfo
75
+ pub ( crate ) fn combine_threshold < I > ( k : usize , sub_timelocks : I ) -> TimelockInfo
76
76
where
77
- I : IntoIterator < Item = TimeLockInfo > ,
77
+ I : IntoIterator < Item = TimelockInfo > ,
78
78
{
79
79
// timelocks calculation
80
80
// Propagate all fields of `TimelockInfo` from each of the node's children to the node
@@ -85,7 +85,7 @@ impl TimeLockInfo {
85
85
// If `k > 1` we have the additional consideration that if any two children have conflicting
86
86
// timelock requirements, this represents an inaccessible spending branch.
87
87
sub_timelocks. into_iter ( ) . fold (
88
- TimeLockInfo :: default ( ) ,
88
+ TimelockInfo :: default ( ) ,
89
89
|mut timelock_info, sub_timelock| {
90
90
// If more than one branch may be taken, and some other branch has a requirement
91
91
// that conflicts with this one, set `contains_combination`
@@ -130,7 +130,7 @@ pub struct ExtData {
130
130
/// the cost for the witness stack, the second one is the cost for scriptSig.
131
131
pub max_dissat_size : Option < ( usize , usize ) > ,
132
132
/// The timelock info about heightlocks and timelocks
133
- pub timelock_info : TimeLockInfo ,
133
+ pub timelock_info : TimelockInfo ,
134
134
/// Maximum stack + alt stack size during satisfaction execution
135
135
/// This does **not** include initial witness elements. This element only captures
136
136
/// the additional elements that are pushed during execution.
@@ -162,7 +162,7 @@ impl Property for ExtData {
162
162
stack_elem_count_dissat : None ,
163
163
max_sat_size : Some ( ( 0 , 0 ) ) ,
164
164
max_dissat_size : None ,
165
- timelock_info : TimeLockInfo :: default ( ) ,
165
+ timelock_info : TimelockInfo :: default ( ) ,
166
166
exec_stack_elem_count_sat : Some ( 1 ) ,
167
167
exec_stack_elem_count_dissat : None ,
168
168
}
@@ -177,7 +177,7 @@ impl Property for ExtData {
177
177
stack_elem_count_dissat : Some ( 0 ) ,
178
178
max_sat_size : None ,
179
179
max_dissat_size : Some ( ( 0 , 0 ) ) ,
180
- timelock_info : TimeLockInfo :: default ( ) ,
180
+ timelock_info : TimelockInfo :: default ( ) ,
181
181
exec_stack_elem_count_sat : None ,
182
182
exec_stack_elem_count_dissat : Some ( 1 ) ,
183
183
}
@@ -192,7 +192,7 @@ impl Property for ExtData {
192
192
stack_elem_count_dissat : Some ( 1 ) ,
193
193
max_sat_size : Some ( ( 73 , 73 ) ) ,
194
194
max_dissat_size : Some ( ( 1 , 1 ) ) ,
195
- timelock_info : TimeLockInfo :: default ( ) ,
195
+ timelock_info : TimelockInfo :: default ( ) ,
196
196
exec_stack_elem_count_sat : Some ( 1 ) , // pushes the pk
197
197
exec_stack_elem_count_dissat : Some ( 1 ) ,
198
198
}
@@ -207,7 +207,7 @@ impl Property for ExtData {
207
207
stack_elem_count_dissat : Some ( 2 ) ,
208
208
max_sat_size : Some ( ( 34 + 73 , 34 + 73 ) ) ,
209
209
max_dissat_size : Some ( ( 35 , 35 ) ) ,
210
- timelock_info : TimeLockInfo :: default ( ) ,
210
+ timelock_info : TimelockInfo :: default ( ) ,
211
211
exec_stack_elem_count_sat : Some ( 2 ) , // dup and hash push
212
212
exec_stack_elem_count_dissat : Some ( 2 ) ,
213
213
}
@@ -230,7 +230,7 @@ impl Property for ExtData {
230
230
stack_elem_count_dissat : Some ( k + 1 ) ,
231
231
max_sat_size : Some ( ( 1 + 73 * k, 1 + 73 * k) ) ,
232
232
max_dissat_size : Some ( ( 1 + k, 1 + k) ) ,
233
- timelock_info : TimeLockInfo :: default ( ) ,
233
+ timelock_info : TimelockInfo :: default ( ) ,
234
234
exec_stack_elem_count_sat : Some ( n) , // n pks
235
235
exec_stack_elem_count_dissat : Some ( n) ,
236
236
}
@@ -252,7 +252,7 @@ impl Property for ExtData {
252
252
stack_elem_count_dissat : Some ( n) ,
253
253
max_sat_size : Some ( ( ( n - k) + 66 * k, ( n - k) + 66 * k) ) ,
254
254
max_dissat_size : Some ( ( n, n) ) ,
255
- timelock_info : TimeLockInfo :: default ( ) ,
255
+ timelock_info : TimelockInfo :: default ( ) ,
256
256
exec_stack_elem_count_sat : Some ( 2 ) , // the two nums before num equal verify
257
257
exec_stack_elem_count_dissat : Some ( 2 ) ,
258
258
}
@@ -272,7 +272,7 @@ impl Property for ExtData {
272
272
stack_elem_count_dissat : Some ( 1 ) ,
273
273
max_sat_size : Some ( ( 33 , 33 ) ) ,
274
274
max_dissat_size : Some ( ( 33 , 33 ) ) ,
275
- timelock_info : TimeLockInfo :: default ( ) ,
275
+ timelock_info : TimelockInfo :: default ( ) ,
276
276
exec_stack_elem_count_sat : Some ( 2 ) , // either size <32> or <hash256> <32 byte>
277
277
exec_stack_elem_count_dissat : Some ( 2 ) ,
278
278
}
@@ -287,7 +287,7 @@ impl Property for ExtData {
287
287
stack_elem_count_dissat : Some ( 1 ) ,
288
288
max_sat_size : Some ( ( 33 , 33 ) ) ,
289
289
max_dissat_size : Some ( ( 33 , 33 ) ) ,
290
- timelock_info : TimeLockInfo :: default ( ) ,
290
+ timelock_info : TimelockInfo :: default ( ) ,
291
291
exec_stack_elem_count_sat : Some ( 2 ) , // either size <32> or <hash256> <32 byte>
292
292
exec_stack_elem_count_dissat : Some ( 2 ) ,
293
293
}
@@ -302,7 +302,7 @@ impl Property for ExtData {
302
302
stack_elem_count_dissat : Some ( 1 ) ,
303
303
max_sat_size : Some ( ( 33 , 33 ) ) ,
304
304
max_dissat_size : Some ( ( 33 , 33 ) ) ,
305
- timelock_info : TimeLockInfo :: default ( ) ,
305
+ timelock_info : TimelockInfo :: default ( ) ,
306
306
exec_stack_elem_count_sat : Some ( 2 ) , // either size <32> or <hash256> <20 byte>
307
307
exec_stack_elem_count_dissat : Some ( 2 ) ,
308
308
}
@@ -317,7 +317,7 @@ impl Property for ExtData {
317
317
stack_elem_count_dissat : Some ( 1 ) ,
318
318
max_sat_size : Some ( ( 33 , 33 ) ) ,
319
319
max_dissat_size : Some ( ( 33 , 33 ) ) ,
320
- timelock_info : TimeLockInfo :: default ( ) ,
320
+ timelock_info : TimelockInfo :: default ( ) ,
321
321
exec_stack_elem_count_sat : Some ( 2 ) , // either size <32> or <hash256> <20 byte>
322
322
exec_stack_elem_count_dissat : Some ( 2 ) ,
323
323
}
@@ -336,7 +336,7 @@ impl Property for ExtData {
336
336
stack_elem_count_dissat : None ,
337
337
max_sat_size : Some ( ( 0 , 0 ) ) ,
338
338
max_dissat_size : None ,
339
- timelock_info : TimeLockInfo {
339
+ timelock_info : TimelockInfo {
340
340
csv_with_height : false ,
341
341
csv_with_time : false ,
342
342
cltv_with_height : t < LOCKTIME_THRESHOLD ,
@@ -357,7 +357,7 @@ impl Property for ExtData {
357
357
stack_elem_count_dissat : None ,
358
358
max_sat_size : Some ( ( 0 , 0 ) ) ,
359
359
max_dissat_size : None ,
360
- timelock_info : TimeLockInfo {
360
+ timelock_info : TimelockInfo {
361
361
csv_with_height : ( t & SEQUENCE_LOCKTIME_TYPE_FLAG ) == 0 ,
362
362
csv_with_time : ( t & SEQUENCE_LOCKTIME_TYPE_FLAG ) != 0 ,
363
363
cltv_with_height : false ,
@@ -505,7 +505,7 @@ impl Property for ExtData {
505
505
max_dissat_size : l
506
506
. max_dissat_size
507
507
. and_then ( |( lw, ls) | r. max_dissat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
508
- timelock_info : TimeLockInfo :: combine_and ( l. timelock_info , r. timelock_info ) ,
508
+ timelock_info : TimelockInfo :: combine_and ( l. timelock_info , r. timelock_info ) ,
509
509
// Left element leaves a stack result on the stack top and then right element is evaluated
510
510
// Therefore + 1 is added to execution size of second element
511
511
exec_stack_elem_count_sat : opt_max (
@@ -536,7 +536,7 @@ impl Property for ExtData {
536
536
. max_sat_size
537
537
. and_then ( |( lw, ls) | r. max_sat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
538
538
max_dissat_size : None ,
539
- timelock_info : TimeLockInfo :: combine_and ( l. timelock_info , r. timelock_info ) ,
539
+ timelock_info : TimelockInfo :: combine_and ( l. timelock_info , r. timelock_info ) ,
540
540
// [X] leaves no element after evaluation, hence this is the max
541
541
exec_stack_elem_count_sat : opt_max (
542
542
l. exec_stack_elem_count_sat ,
@@ -576,7 +576,7 @@ impl Property for ExtData {
576
576
max_dissat_size : l
577
577
. max_dissat_size
578
578
. and_then ( |( lw, ls) | r. max_dissat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
579
- timelock_info : TimeLockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
579
+ timelock_info : TimelockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
580
580
exec_stack_elem_count_sat : cmp:: max (
581
581
opt_max (
582
582
l. exec_stack_elem_count_sat ,
@@ -619,7 +619,7 @@ impl Property for ExtData {
619
619
max_dissat_size : l
620
620
. max_dissat_size
621
621
. and_then ( |( lw, ls) | r. max_dissat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
622
- timelock_info : TimeLockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
622
+ timelock_info : TimelockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
623
623
exec_stack_elem_count_sat : cmp:: max (
624
624
l. exec_stack_elem_count_sat ,
625
625
opt_max ( r. exec_stack_elem_count_sat , l. exec_stack_elem_count_dissat ) ,
@@ -653,7 +653,7 @@ impl Property for ExtData {
653
653
. and_then ( |( lw, ls) | r. max_sat_size . map ( |( rw, rs) | ( lw + rw, ls + rs) ) ) ,
654
654
) ,
655
655
max_dissat_size : None ,
656
- timelock_info : TimeLockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
656
+ timelock_info : TimelockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
657
657
exec_stack_elem_count_sat : cmp:: max (
658
658
l. exec_stack_elem_count_sat ,
659
659
opt_max ( r. exec_stack_elem_count_sat , l. exec_stack_elem_count_dissat ) ,
@@ -696,7 +696,7 @@ impl Property for ExtData {
696
696
( Some ( l) , None ) => Some ( ( 2 + l. 0 , 1 + l. 1 ) ) ,
697
697
( None , None ) => None ,
698
698
} ,
699
- timelock_info : TimeLockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
699
+ timelock_info : TimelockInfo :: combine_or ( l. timelock_info , r. timelock_info ) ,
700
700
// TODO: fix elem count dissat bug
701
701
exec_stack_elem_count_sat : cmp:: max (
702
702
l. exec_stack_elem_count_sat ,
@@ -739,8 +739,8 @@ impl Property for ExtData {
739
739
max_dissat_size : a
740
740
. max_dissat_size
741
741
. and_then ( |( wa, sa) | c. max_dissat_size . map ( |( wc, sc) | ( wa + wc, sa + sc) ) ) ,
742
- timelock_info : TimeLockInfo :: combine_or (
743
- TimeLockInfo :: combine_and ( a. timelock_info , b. timelock_info ) ,
742
+ timelock_info : TimelockInfo :: combine_or (
743
+ TimelockInfo :: combine_and ( a. timelock_info , b. timelock_info ) ,
744
744
c. timelock_info ,
745
745
) ,
746
746
exec_stack_elem_count_sat : cmp:: max (
@@ -876,7 +876,7 @@ impl Property for ExtData {
876
876
stack_elem_count_dissat,
877
877
max_sat_size,
878
878
max_dissat_size,
879
- timelock_info : TimeLockInfo :: combine_threshold ( k, timelocks) ,
879
+ timelock_info : TimelockInfo :: combine_threshold ( k, timelocks) ,
880
880
exec_stack_elem_count_sat,
881
881
exec_stack_elem_count_dissat,
882
882
} )
0 commit comments