Skip to content

Commit b6887d6

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 c00d6fb commit b6887d6

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
@@ -12,7 +12,7 @@ use crate::{script_num_size, MiniscriptKey, Terminal};
1212

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

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

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
7676
where
77-
I: IntoIterator<Item = TimeLockInfo>,
77+
I: IntoIterator<Item = TimelockInfo>,
7878
{
7979
// timelocks calculation
8080
// Propagate all fields of `TimelockInfo` from each of the node's children to the node
@@ -85,7 +85,7 @@ impl TimeLockInfo {
8585
// If `k > 1` we have the additional consideration that if any two children have conflicting
8686
// timelock requirements, this represents an inaccessible spending branch.
8787
sub_timelocks.into_iter().fold(
88-
TimeLockInfo::default(),
88+
TimelockInfo::default(),
8989
|mut timelock_info, sub_timelock| {
9090
// If more than one branch may be taken, and some other branch has a requirement
9191
// that conflicts with this one, set `contains_combination`
@@ -130,7 +130,7 @@ pub struct ExtData {
130130
/// the cost for the witness stack, the second one is the cost for scriptSig.
131131
pub max_dissat_size: Option<(usize, usize)>,
132132
/// The timelock info about heightlocks and timelocks
133-
pub timelock_info: TimeLockInfo,
133+
pub timelock_info: TimelockInfo,
134134
/// Maximum stack + alt stack size during satisfaction execution
135135
/// This does **not** include initial witness elements. This element only captures
136136
/// the additional elements that are pushed during execution.
@@ -162,7 +162,7 @@ impl Property for ExtData {
162162
stack_elem_count_dissat: None,
163163
max_sat_size: Some((0, 0)),
164164
max_dissat_size: None,
165-
timelock_info: TimeLockInfo::default(),
165+
timelock_info: TimelockInfo::default(),
166166
exec_stack_elem_count_sat: Some(1),
167167
exec_stack_elem_count_dissat: None,
168168
}
@@ -177,7 +177,7 @@ impl Property for ExtData {
177177
stack_elem_count_dissat: Some(0),
178178
max_sat_size: None,
179179
max_dissat_size: Some((0, 0)),
180-
timelock_info: TimeLockInfo::default(),
180+
timelock_info: TimelockInfo::default(),
181181
exec_stack_elem_count_sat: None,
182182
exec_stack_elem_count_dissat: Some(1),
183183
}
@@ -192,7 +192,7 @@ impl Property for ExtData {
192192
stack_elem_count_dissat: Some(1),
193193
max_sat_size: Some((73, 73)),
194194
max_dissat_size: Some((1, 1)),
195-
timelock_info: TimeLockInfo::default(),
195+
timelock_info: TimelockInfo::default(),
196196
exec_stack_elem_count_sat: Some(1), // pushes the pk
197197
exec_stack_elem_count_dissat: Some(1),
198198
}
@@ -207,7 +207,7 @@ impl Property for ExtData {
207207
stack_elem_count_dissat: Some(2),
208208
max_sat_size: Some((34 + 73, 34 + 73)),
209209
max_dissat_size: Some((35, 35)),
210-
timelock_info: TimeLockInfo::default(),
210+
timelock_info: TimelockInfo::default(),
211211
exec_stack_elem_count_sat: Some(2), // dup and hash push
212212
exec_stack_elem_count_dissat: Some(2),
213213
}
@@ -230,7 +230,7 @@ impl Property for ExtData {
230230
stack_elem_count_dissat: Some(k + 1),
231231
max_sat_size: Some((1 + 73 * k, 1 + 73 * k)),
232232
max_dissat_size: Some((1 + k, 1 + k)),
233-
timelock_info: TimeLockInfo::default(),
233+
timelock_info: TimelockInfo::default(),
234234
exec_stack_elem_count_sat: Some(n), // n pks
235235
exec_stack_elem_count_dissat: Some(n),
236236
}
@@ -252,7 +252,7 @@ impl Property for ExtData {
252252
stack_elem_count_dissat: Some(n),
253253
max_sat_size: Some(((n - k) + 66 * k, (n - k) + 66 * k)),
254254
max_dissat_size: Some((n, n)),
255-
timelock_info: TimeLockInfo::default(),
255+
timelock_info: TimelockInfo::default(),
256256
exec_stack_elem_count_sat: Some(2), // the two nums before num equal verify
257257
exec_stack_elem_count_dissat: Some(2),
258258
}
@@ -272,7 +272,7 @@ impl Property for ExtData {
272272
stack_elem_count_dissat: Some(1),
273273
max_sat_size: Some((33, 33)),
274274
max_dissat_size: Some((33, 33)),
275-
timelock_info: TimeLockInfo::default(),
275+
timelock_info: TimelockInfo::default(),
276276
exec_stack_elem_count_sat: Some(2), // either size <32> or <hash256> <32 byte>
277277
exec_stack_elem_count_dissat: Some(2),
278278
}
@@ -287,7 +287,7 @@ impl Property for ExtData {
287287
stack_elem_count_dissat: Some(1),
288288
max_sat_size: Some((33, 33)),
289289
max_dissat_size: Some((33, 33)),
290-
timelock_info: TimeLockInfo::default(),
290+
timelock_info: TimelockInfo::default(),
291291
exec_stack_elem_count_sat: Some(2), // either size <32> or <hash256> <32 byte>
292292
exec_stack_elem_count_dissat: Some(2),
293293
}
@@ -302,7 +302,7 @@ impl Property for ExtData {
302302
stack_elem_count_dissat: Some(1),
303303
max_sat_size: Some((33, 33)),
304304
max_dissat_size: Some((33, 33)),
305-
timelock_info: TimeLockInfo::default(),
305+
timelock_info: TimelockInfo::default(),
306306
exec_stack_elem_count_sat: Some(2), // either size <32> or <hash256> <20 byte>
307307
exec_stack_elem_count_dissat: Some(2),
308308
}
@@ -317,7 +317,7 @@ impl Property for ExtData {
317317
stack_elem_count_dissat: Some(1),
318318
max_sat_size: Some((33, 33)),
319319
max_dissat_size: Some((33, 33)),
320-
timelock_info: TimeLockInfo::default(),
320+
timelock_info: TimelockInfo::default(),
321321
exec_stack_elem_count_sat: Some(2), // either size <32> or <hash256> <20 byte>
322322
exec_stack_elem_count_dissat: Some(2),
323323
}
@@ -336,7 +336,7 @@ impl Property for ExtData {
336336
stack_elem_count_dissat: None,
337337
max_sat_size: Some((0, 0)),
338338
max_dissat_size: None,
339-
timelock_info: TimeLockInfo {
339+
timelock_info: TimelockInfo {
340340
csv_with_height: false,
341341
csv_with_time: false,
342342
cltv_with_height: t < LOCKTIME_THRESHOLD,
@@ -357,7 +357,7 @@ impl Property for ExtData {
357357
stack_elem_count_dissat: None,
358358
max_sat_size: Some((0, 0)),
359359
max_dissat_size: None,
360-
timelock_info: TimeLockInfo {
360+
timelock_info: TimelockInfo {
361361
csv_with_height: (t & SEQUENCE_LOCKTIME_TYPE_FLAG) == 0,
362362
csv_with_time: (t & SEQUENCE_LOCKTIME_TYPE_FLAG) != 0,
363363
cltv_with_height: false,
@@ -505,7 +505,7 @@ impl Property for ExtData {
505505
max_dissat_size: l
506506
.max_dissat_size
507507
.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),
509509
// Left element leaves a stack result on the stack top and then right element is evaluated
510510
// Therefore + 1 is added to execution size of second element
511511
exec_stack_elem_count_sat: opt_max(
@@ -536,7 +536,7 @@ impl Property for ExtData {
536536
.max_sat_size
537537
.and_then(|(lw, ls)| r.max_sat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
538538
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),
540540
// [X] leaves no element after evaluation, hence this is the max
541541
exec_stack_elem_count_sat: opt_max(
542542
l.exec_stack_elem_count_sat,
@@ -576,7 +576,7 @@ impl Property for ExtData {
576576
max_dissat_size: l
577577
.max_dissat_size
578578
.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),
580580
exec_stack_elem_count_sat: cmp::max(
581581
opt_max(
582582
l.exec_stack_elem_count_sat,
@@ -619,7 +619,7 @@ impl Property for ExtData {
619619
max_dissat_size: l
620620
.max_dissat_size
621621
.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),
623623
exec_stack_elem_count_sat: cmp::max(
624624
l.exec_stack_elem_count_sat,
625625
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
@@ -653,7 +653,7 @@ impl Property for ExtData {
653653
.and_then(|(lw, ls)| r.max_sat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
654654
),
655655
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),
657657
exec_stack_elem_count_sat: cmp::max(
658658
l.exec_stack_elem_count_sat,
659659
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
@@ -696,7 +696,7 @@ impl Property for ExtData {
696696
(Some(l), None) => Some((2 + l.0, 1 + l.1)),
697697
(None, None) => None,
698698
},
699-
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
699+
timelock_info: TimelockInfo::combine_or(l.timelock_info, r.timelock_info),
700700
// TODO: fix elem count dissat bug
701701
exec_stack_elem_count_sat: cmp::max(
702702
l.exec_stack_elem_count_sat,
@@ -739,8 +739,8 @@ impl Property for ExtData {
739739
max_dissat_size: a
740740
.max_dissat_size
741741
.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),
744744
c.timelock_info,
745745
),
746746
exec_stack_elem_count_sat: cmp::max(
@@ -876,7 +876,7 @@ impl Property for ExtData {
876876
stack_elem_count_dissat,
877877
max_sat_size,
878878
max_dissat_size,
879-
timelock_info: TimeLockInfo::combine_threshold(k, timelocks),
879+
timelock_info: TimelockInfo::combine_threshold(k, timelocks),
880880
exec_stack_elem_count_sat,
881881
exec_stack_elem_count_dissat,
882882
})

src/policy/concrete.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use bitcoin::hashes::{hash160, ripemd160, sha256, sha256d};
2424
use super::ENTAILMENT_MAX_TERMINALS;
2525
use crate::expression::{self, FromTree};
2626
use crate::miniscript::limits::{LOCKTIME_THRESHOLD, SEQUENCE_LOCKTIME_TYPE_FLAG};
27-
use crate::miniscript::types::extra_props::TimeLockInfo;
27+
use crate::miniscript::types::extra_props::TimelockInfo;
2828
#[cfg(feature = "compiler")]
2929
use crate::miniscript::ScriptContext;
3030
#[cfg(feature = "compiler")]
@@ -87,7 +87,7 @@ pub enum PolicyError {
8787
EntailmentMaxTerminals,
8888
/// lifting error: Cannot lift policies that have
8989
/// a combination of height and timelocks.
90-
HeightTimeLockCombination,
90+
HeightTimelockCombination,
9191
/// Duplicate Public Keys
9292
DuplicatePubKeys,
9393
}
@@ -119,7 +119,7 @@ impl fmt::Display for PolicyError {
119119
"Policy entailment only supports {} terminals",
120120
ENTAILMENT_MAX_TERMINALS
121121
),
122-
PolicyError::HeightTimeLockCombination => {
122+
PolicyError::HeightTimelockCombination => {
123123
f.write_str("Cannot lift policies that have a heightlock and timelock combination")
124124
}
125125
PolicyError::DuplicatePubKeys => f.write_str("Policy contains duplicate keys"),
@@ -263,15 +263,15 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
263263
pub fn check_timelocks(&self) -> Result<(), PolicyError> {
264264
let timelocks = self.check_timelocks_helper();
265265
if timelocks.contains_combination {
266-
Err(PolicyError::HeightTimeLockCombination)
266+
Err(PolicyError::HeightTimelockCombination)
267267
} else {
268268
Ok(())
269269
}
270270
}
271271

272272
// Checks whether the given concrete policy contains a combination of
273273
// timelocks and heightlocks
274-
fn check_timelocks_helper(&self) -> TimeLockInfo {
274+
fn check_timelocks_helper(&self) -> TimelockInfo {
275275
// timelocks[csv_h, csv_t, cltv_h, cltv_t, combination]
276276
match *self {
277277
Policy::Unsatisfiable
@@ -280,15 +280,15 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
280280
| Policy::Sha256(_)
281281
| Policy::Hash256(_)
282282
| Policy::Ripemd160(_)
283-
| Policy::Hash160(_) => TimeLockInfo::default(),
284-
Policy::After(t) => TimeLockInfo {
283+
| Policy::Hash160(_) => TimelockInfo::default(),
284+
Policy::After(t) => TimelockInfo {
285285
csv_with_height: false,
286286
csv_with_time: false,
287287
cltv_with_height: t < LOCKTIME_THRESHOLD,
288288
cltv_with_time: t >= LOCKTIME_THRESHOLD,
289289
contains_combination: false,
290290
},
291-
Policy::Older(t) => TimeLockInfo {
291+
Policy::Older(t) => TimelockInfo {
292292
csv_with_height: (t & SEQUENCE_LOCKTIME_TYPE_FLAG) == 0,
293293
csv_with_time: (t & SEQUENCE_LOCKTIME_TYPE_FLAG) != 0,
294294
cltv_with_height: false,
@@ -297,17 +297,17 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
297297
},
298298
Policy::Threshold(k, ref subs) => {
299299
let iter = subs.iter().map(|sub| sub.check_timelocks_helper());
300-
TimeLockInfo::combine_threshold(k, iter)
300+
TimelockInfo::combine_threshold(k, iter)
301301
}
302302
Policy::And(ref subs) => {
303303
let iter = subs.iter().map(|sub| sub.check_timelocks_helper());
304-
TimeLockInfo::combine_threshold(subs.len(), iter)
304+
TimelockInfo::combine_threshold(subs.len(), iter)
305305
}
306306
Policy::Or(ref subs) => {
307307
let iter = subs
308308
.iter()
309309
.map(|&(ref _p, ref sub)| sub.check_timelocks_helper());
310-
TimeLockInfo::combine_threshold(1, iter)
310+
TimelockInfo::combine_threshold(1, iter)
311311
}
312312
}
313313
}

0 commit comments

Comments
 (0)