Skip to content

Commit a36f608

Browse files
committed
Be uniform in spelling of timelock
We currently use the form "time lock" and also "timelock" (implies `TimeLock`, `Timelock`). Which we use is not important but we should be uniform. Favour "timelock" (and `Timelock`).
1 parent 51de643 commit a36f608

File tree

6 files changed

+50
-50
lines changed

6 files changed

+50
-50
lines changed

src/interpreter/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,12 @@ pub enum SatisfiedConstraint {
485485
preimage: [u8; 32],
486486
},
487487
///Relative Timelock for CSV.
488-
RelativeTimeLock {
488+
RelativeTimelock {
489489
/// The value of RelativeTimelock
490490
time: u32,
491491
},
492492
///Absolute Timelock for CLTV.
493-
AbsoluteTimeLock {
493+
AbsoluteTimelock {
494494
/// The value of Absolute timelock
495495
time: u32,
496496
},
@@ -1197,7 +1197,7 @@ mod tests {
11971197
let after_satisfied: Result<Vec<SatisfiedConstraint>, Error> = constraints.collect();
11981198
assert_eq!(
11991199
after_satisfied.unwrap(),
1200-
vec![SatisfiedConstraint::AbsoluteTimeLock { time: 1000 }]
1200+
vec![SatisfiedConstraint::AbsoluteTimelock { time: 1000 }]
12011201
);
12021202

12031203
//Check Older
@@ -1207,7 +1207,7 @@ mod tests {
12071207
let older_satisfied: Result<Vec<SatisfiedConstraint>, Error> = constraints.collect();
12081208
assert_eq!(
12091209
older_satisfied.unwrap(),
1210-
vec![SatisfiedConstraint::RelativeTimeLock { time: 1000 }]
1210+
vec![SatisfiedConstraint::RelativeTimelock { time: 1000 }]
12111211
);
12121212

12131213
//Check Sha256

src/interpreter/stack.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl<'txin> Stack<'txin> {
235235
) -> Option<Result<SatisfiedConstraint, Error>> {
236236
if age >= *n {
237237
self.push(Element::Satisfied);
238-
Some(Ok(SatisfiedConstraint::AbsoluteTimeLock { time: *n }))
238+
Some(Ok(SatisfiedConstraint::AbsoluteTimelock { time: *n }))
239239
} else {
240240
Some(Err(Error::AbsoluteLocktimeNotMet(*n)))
241241
}
@@ -254,7 +254,7 @@ impl<'txin> Stack<'txin> {
254254
) -> Option<Result<SatisfiedConstraint, Error>> {
255255
if height >= *n {
256256
self.push(Element::Satisfied);
257-
Some(Ok(SatisfiedConstraint::RelativeTimeLock { time: *n }))
257+
Some(Ok(SatisfiedConstraint::RelativeTimelock { time: *n }))
258258
} else {
259259
Some(Err(Error::RelativeLocktimeNotMet(*n)))
260260
}

src/miniscript/analyzable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum AnalysisError {
4141
/// Miniscript contains at least one path that exceeds resource limits
4242
BranchExceedResouceLimits,
4343
/// Contains a combination of heightlock and timelock
44-
HeightTimeLockCombination,
44+
HeightTimelockCombination,
4545
/// Malleable script
4646
Malleable,
4747
}
@@ -58,7 +58,7 @@ impl fmt::Display for AnalysisError {
5858
AnalysisError::BranchExceedResouceLimits => {
5959
f.write_str("At least one spend path exceeds the resource limits(stack depth/satisfaction size..)")
6060
}
61-
AnalysisError::HeightTimeLockCombination => {
61+
AnalysisError::HeightTimelockCombination => {
6262
f.write_str("Contains a combination of heightlock and timelock")
6363
}
6464
AnalysisError::Malleable => f.write_str("Miniscript is malleable")
@@ -128,7 +128,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
128128
} else if self.has_repeated_keys() {
129129
Err(AnalysisError::RepeatedPubkeys)
130130
} else if self.has_mixed_timelocks() {
131-
Err(AnalysisError::HeightTimeLockCombination)
131+
Err(AnalysisError::HeightTimelockCombination)
132132
} else {
133133
Ok(())
134134
}

src/miniscript/types/extra_props.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{script_num_size, MiniscriptKey, Terminal};
1313

1414
/// Helper struct Whether any satisfaction of this fragment contains any timelocks
1515
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
16-
pub struct TimeLockInfo {
16+
pub struct TimelockInfo {
1717
/// csv with heights
1818
pub csv_with_height: bool,
1919
/// csv with times
@@ -54,7 +54,7 @@ impl OpLimits {
5454
}
5555
}
5656

57-
impl TimeLockInfo {
57+
impl TimelockInfo {
5858
/// Whether the current contains any possible unspendable
5959
/// path
6060
pub fn contains_unspendable_path(self) -> bool {
@@ -73,9 +73,9 @@ impl TimeLockInfo {
7373
Self::combine_threshold(1, once(a).chain(once(b)))
7474
}
7575

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
7777
where
78-
I: IntoIterator<Item = TimeLockInfo>,
78+
I: IntoIterator<Item = TimelockInfo>,
7979
{
8080
// timelocks calculation
8181
// Propagate all fields of `TimelockInfo` from each of the node's children to the node
@@ -86,7 +86,7 @@ impl TimeLockInfo {
8686
// If `k > 1` we have the additional consideration that if any two children have conflicting
8787
// timelock requirements, this represents an inaccessible spending branch.
8888
sub_timelocks.into_iter().fold(
89-
TimeLockInfo::default(),
89+
TimelockInfo::default(),
9090
|mut timelock_info, sub_timelock| {
9191
// If more than one branch may be taken, and some other branch has a requirement
9292
// that conflicts with this one, set `contains_combination`
@@ -131,7 +131,7 @@ pub struct ExtData {
131131
/// the cost for the witness stack, the second one is the cost for scriptSig.
132132
pub max_dissat_size: Option<(usize, usize)>,
133133
/// The timelock info about heightlocks and timelocks
134-
pub timelock_info: TimeLockInfo,
134+
pub timelock_info: TimelockInfo,
135135
/// Maximum stack + alt stack size during satisfaction execution
136136
/// This does **not** include initial witness elements. This element only captures
137137
/// the additional elements that are pushed during execution.
@@ -163,7 +163,7 @@ impl Property for ExtData {
163163
stack_elem_count_dissat: None,
164164
max_sat_size: Some((0, 0)),
165165
max_dissat_size: None,
166-
timelock_info: TimeLockInfo::default(),
166+
timelock_info: TimelockInfo::default(),
167167
exec_stack_elem_count_sat: Some(1),
168168
exec_stack_elem_count_dissat: None,
169169
}
@@ -178,7 +178,7 @@ impl Property for ExtData {
178178
stack_elem_count_dissat: Some(0),
179179
max_sat_size: None,
180180
max_dissat_size: Some((0, 0)),
181-
timelock_info: TimeLockInfo::default(),
181+
timelock_info: TimelockInfo::default(),
182182
exec_stack_elem_count_sat: None,
183183
exec_stack_elem_count_dissat: Some(1),
184184
}
@@ -199,7 +199,7 @@ impl Property for ExtData {
199199
SigType::Schnorr => Some((66, 66)),
200200
},
201201
max_dissat_size: Some((1, 1)),
202-
timelock_info: TimeLockInfo::default(),
202+
timelock_info: TimelockInfo::default(),
203203
exec_stack_elem_count_sat: Some(1), // pushes the pk
204204
exec_stack_elem_count_dissat: Some(1),
205205
}
@@ -220,7 +220,7 @@ impl Property for ExtData {
220220
SigType::Ecdsa => Some((35, 35)),
221221
SigType::Schnorr => Some((34, 34)),
222222
},
223-
timelock_info: TimeLockInfo::default(),
223+
timelock_info: TimelockInfo::default(),
224224
exec_stack_elem_count_sat: Some(2), // dup and hash push
225225
exec_stack_elem_count_dissat: Some(2),
226226
}
@@ -243,7 +243,7 @@ impl Property for ExtData {
243243
stack_elem_count_dissat: Some(k + 1),
244244
max_sat_size: Some((1 + 73 * k, 1 + 73 * k)),
245245
max_dissat_size: Some((1 + k, 1 + k)),
246-
timelock_info: TimeLockInfo::default(),
246+
timelock_info: TimelockInfo::default(),
247247
exec_stack_elem_count_sat: Some(n), // n pks
248248
exec_stack_elem_count_dissat: Some(n),
249249
}
@@ -265,7 +265,7 @@ impl Property for ExtData {
265265
stack_elem_count_dissat: Some(n),
266266
max_sat_size: Some(((n - k) + 66 * k, (n - k) + 66 * k)),
267267
max_dissat_size: Some((n, n)),
268-
timelock_info: TimeLockInfo::default(),
268+
timelock_info: TimelockInfo::default(),
269269
exec_stack_elem_count_sat: Some(2), // the two nums before num equal verify
270270
exec_stack_elem_count_dissat: Some(2),
271271
}
@@ -285,7 +285,7 @@ impl Property for ExtData {
285285
stack_elem_count_dissat: Some(1),
286286
max_sat_size: Some((33, 33)),
287287
max_dissat_size: Some((33, 33)),
288-
timelock_info: TimeLockInfo::default(),
288+
timelock_info: TimelockInfo::default(),
289289
exec_stack_elem_count_sat: Some(2), // either size <32> or <hash256> <32 byte>
290290
exec_stack_elem_count_dissat: Some(2),
291291
}
@@ -300,7 +300,7 @@ impl Property for ExtData {
300300
stack_elem_count_dissat: Some(1),
301301
max_sat_size: Some((33, 33)),
302302
max_dissat_size: Some((33, 33)),
303-
timelock_info: TimeLockInfo::default(),
303+
timelock_info: TimelockInfo::default(),
304304
exec_stack_elem_count_sat: Some(2), // either size <32> or <hash256> <32 byte>
305305
exec_stack_elem_count_dissat: Some(2),
306306
}
@@ -315,7 +315,7 @@ impl Property for ExtData {
315315
stack_elem_count_dissat: Some(1),
316316
max_sat_size: Some((33, 33)),
317317
max_dissat_size: Some((33, 33)),
318-
timelock_info: TimeLockInfo::default(),
318+
timelock_info: TimelockInfo::default(),
319319
exec_stack_elem_count_sat: Some(2), // either size <32> or <hash256> <20 byte>
320320
exec_stack_elem_count_dissat: Some(2),
321321
}
@@ -330,7 +330,7 @@ impl Property for ExtData {
330330
stack_elem_count_dissat: Some(1),
331331
max_sat_size: Some((33, 33)),
332332
max_dissat_size: Some((33, 33)),
333-
timelock_info: TimeLockInfo::default(),
333+
timelock_info: TimelockInfo::default(),
334334
exec_stack_elem_count_sat: Some(2), // either size <32> or <hash256> <20 byte>
335335
exec_stack_elem_count_dissat: Some(2),
336336
}
@@ -349,7 +349,7 @@ impl Property for ExtData {
349349
stack_elem_count_dissat: None,
350350
max_sat_size: Some((0, 0)),
351351
max_dissat_size: None,
352-
timelock_info: TimeLockInfo {
352+
timelock_info: TimelockInfo {
353353
csv_with_height: false,
354354
csv_with_time: false,
355355
cltv_with_height: t < LOCKTIME_THRESHOLD,
@@ -370,7 +370,7 @@ impl Property for ExtData {
370370
stack_elem_count_dissat: None,
371371
max_sat_size: Some((0, 0)),
372372
max_dissat_size: None,
373-
timelock_info: TimeLockInfo {
373+
timelock_info: TimelockInfo {
374374
csv_with_height: (t & SEQUENCE_LOCKTIME_TYPE_FLAG) == 0,
375375
csv_with_time: (t & SEQUENCE_LOCKTIME_TYPE_FLAG) != 0,
376376
cltv_with_height: false,
@@ -518,7 +518,7 @@ impl Property for ExtData {
518518
max_dissat_size: l
519519
.max_dissat_size
520520
.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),
522522
// Left element leaves a stack result on the stack top and then right element is evaluated
523523
// Therefore + 1 is added to execution size of second element
524524
exec_stack_elem_count_sat: opt_max(
@@ -549,7 +549,7 @@ impl Property for ExtData {
549549
.max_sat_size
550550
.and_then(|(lw, ls)| r.max_sat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
551551
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),
553553
// [X] leaves no element after evaluation, hence this is the max
554554
exec_stack_elem_count_sat: opt_max(
555555
l.exec_stack_elem_count_sat,
@@ -589,7 +589,7 @@ impl Property for ExtData {
589589
max_dissat_size: l
590590
.max_dissat_size
591591
.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),
593593
exec_stack_elem_count_sat: cmp::max(
594594
opt_max(
595595
l.exec_stack_elem_count_sat,
@@ -632,7 +632,7 @@ impl Property for ExtData {
632632
max_dissat_size: l
633633
.max_dissat_size
634634
.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),
636636
exec_stack_elem_count_sat: cmp::max(
637637
l.exec_stack_elem_count_sat,
638638
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
@@ -666,7 +666,7 @@ impl Property for ExtData {
666666
.and_then(|(lw, ls)| r.max_sat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
667667
),
668668
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),
670670
exec_stack_elem_count_sat: cmp::max(
671671
l.exec_stack_elem_count_sat,
672672
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
@@ -709,7 +709,7 @@ impl Property for ExtData {
709709
(Some(l), None) => Some((2 + l.0, 1 + l.1)),
710710
(None, None) => None,
711711
},
712-
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
712+
timelock_info: TimelockInfo::combine_or(l.timelock_info, r.timelock_info),
713713
// TODO: fix elem count dissat bug
714714
exec_stack_elem_count_sat: cmp::max(
715715
l.exec_stack_elem_count_sat,
@@ -752,8 +752,8 @@ impl Property for ExtData {
752752
max_dissat_size: a
753753
.max_dissat_size
754754
.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),
757757
c.timelock_info,
758758
),
759759
exec_stack_elem_count_sat: cmp::max(
@@ -884,7 +884,7 @@ impl Property for ExtData {
884884
stack_elem_count_dissat,
885885
max_sat_size,
886886
max_dissat_size,
887-
timelock_info: TimeLockInfo::combine_threshold(k, timelocks),
887+
timelock_info: TimelockInfo::combine_threshold(k, timelocks),
888888
exec_stack_elem_count_sat,
889889
exec_stack_elem_count_dissat,
890890
})

src/policy/concrete.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use {
3838
use super::ENTAILMENT_MAX_TERMINALS;
3939
use crate::expression::{self, FromTree};
4040
use crate::miniscript::limits::{LOCKTIME_THRESHOLD, SEQUENCE_LOCKTIME_TYPE_FLAG};
41-
use crate::miniscript::types::extra_props::TimeLockInfo;
41+
use crate::miniscript::types::extra_props::TimelockInfo;
4242
use crate::{errstr, Error, ForEach, ForEachKey, MiniscriptKey};
4343

4444
/// Concrete policy which corresponds directly to a Miniscript structure,
@@ -94,7 +94,7 @@ pub enum PolicyError {
9494
EntailmentMaxTerminals,
9595
/// lifting error: Cannot lift policies that have
9696
/// a combination of height and timelocks.
97-
HeightTimeLockCombination,
97+
HeightTimelockCombination,
9898
/// Duplicate Public Keys
9999
DuplicatePubKeys,
100100
}
@@ -126,7 +126,7 @@ impl fmt::Display for PolicyError {
126126
"Policy entailment only supports {} terminals",
127127
ENTAILMENT_MAX_TERMINALS
128128
),
129-
PolicyError::HeightTimeLockCombination => {
129+
PolicyError::HeightTimelockCombination => {
130130
f.write_str("Cannot lift policies that have a heightlock and timelock combination")
131131
}
132132
PolicyError::DuplicatePubKeys => f.write_str("Policy contains duplicate keys"),
@@ -424,15 +424,15 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
424424
pub fn check_timelocks(&self) -> Result<(), PolicyError> {
425425
let timelocks = self.check_timelocks_helper();
426426
if timelocks.contains_combination {
427-
Err(PolicyError::HeightTimeLockCombination)
427+
Err(PolicyError::HeightTimelockCombination)
428428
} else {
429429
Ok(())
430430
}
431431
}
432432

433433
// Checks whether the given concrete policy contains a combination of
434434
// timelocks and heightlocks
435-
fn check_timelocks_helper(&self) -> TimeLockInfo {
435+
fn check_timelocks_helper(&self) -> TimelockInfo {
436436
// timelocks[csv_h, csv_t, cltv_h, cltv_t, combination]
437437
match *self {
438438
Policy::Unsatisfiable
@@ -441,15 +441,15 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
441441
| Policy::Sha256(_)
442442
| Policy::Hash256(_)
443443
| Policy::Ripemd160(_)
444-
| Policy::Hash160(_) => TimeLockInfo::default(),
445-
Policy::After(t) => TimeLockInfo {
444+
| Policy::Hash160(_) => TimelockInfo::default(),
445+
Policy::After(t) => TimelockInfo {
446446
csv_with_height: false,
447447
csv_with_time: false,
448448
cltv_with_height: t < LOCKTIME_THRESHOLD,
449449
cltv_with_time: t >= LOCKTIME_THRESHOLD,
450450
contains_combination: false,
451451
},
452-
Policy::Older(t) => TimeLockInfo {
452+
Policy::Older(t) => TimelockInfo {
453453
csv_with_height: (t & SEQUENCE_LOCKTIME_TYPE_FLAG) == 0,
454454
csv_with_time: (t & SEQUENCE_LOCKTIME_TYPE_FLAG) != 0,
455455
cltv_with_height: false,
@@ -458,17 +458,17 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
458458
},
459459
Policy::Threshold(k, ref subs) => {
460460
let iter = subs.iter().map(|sub| sub.check_timelocks_helper());
461-
TimeLockInfo::combine_threshold(k, iter)
461+
TimelockInfo::combine_threshold(k, iter)
462462
}
463463
Policy::And(ref subs) => {
464464
let iter = subs.iter().map(|sub| sub.check_timelocks_helper());
465-
TimeLockInfo::combine_threshold(subs.len(), iter)
465+
TimelockInfo::combine_threshold(subs.len(), iter)
466466
}
467467
Policy::Or(ref subs) => {
468468
let iter = subs
469469
.iter()
470470
.map(|&(ref _p, ref sub)| sub.check_timelocks_helper());
471-
TimeLockInfo::combine_threshold(1, iter)
471+
TimelockInfo::combine_threshold(1, iter)
472472
}
473473
}
474474
}

0 commit comments

Comments
 (0)