Skip to content

Commit fec8014

Browse files
committed
Use lock_time instead of height
Currently we are using the identifier `height` for the CLTV vaule. This is incorrect because the value can be either a height or time. There is also a risk of mixing up the value with the CSV `age` value. Use `lock_time` to clearly disambiguate the CLTV value.
1 parent 3d76d02 commit fec8014

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/interpreter/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub struct Interpreter<'txin> {
4949
/// is the leaf script; for key-spends it is `None`.
5050
script_code: Option<bitcoin::Script>,
5151
age: u32,
52-
height: u32,
52+
lock_time: u32,
5353
}
5454

5555
// A type representing functions for checking signatures that accept both
@@ -169,16 +169,16 @@ impl<'txin> Interpreter<'txin> {
169169
spk: &bitcoin::Script,
170170
script_sig: &'txin bitcoin::Script,
171171
witness: &'txin Witness,
172-
age: u32, // CSV, relative lock time.
173-
height: u32, // CLTV, absolute lock time.
172+
age: u32, // CSV, relative lock time.
173+
lock_time: u32, // CLTV, absolute lock time.
174174
) -> Result<Self, Error> {
175175
let (inner, stack, script_code) = inner::from_txdata(spk, script_sig, witness)?;
176176
Ok(Interpreter {
177177
inner,
178178
stack,
179179
script_code,
180180
age,
181-
height,
181+
lock_time,
182182
})
183183
}
184184

@@ -209,7 +209,7 @@ impl<'txin> Interpreter<'txin> {
209209
// call interpreter.iter() without mutating interpreter
210210
stack: self.stack.clone(),
211211
age: self.age,
212-
height: self.height,
212+
lock_time: self.lock_time,
213213
has_errored: false,
214214
}
215215
}
@@ -528,7 +528,7 @@ pub struct Iter<'intp, 'txin: 'intp> {
528528
state: Vec<NodeEvaluationState<'intp>>,
529529
stack: Stack<'txin>,
530530
age: u32,
531-
height: u32,
531+
lock_time: u32,
532532
has_errored: bool,
533533
}
534534

@@ -605,7 +605,7 @@ where
605605
Terminal::After(ref n) => {
606606
debug_assert_eq!(node_state.n_evaluated, 0);
607607
debug_assert_eq!(node_state.n_satisfied, 0);
608-
let res = self.stack.evaluate_after(n, self.height);
608+
let res = self.stack.evaluate_after(n, self.lock_time);
609609
if res.is_some() {
610610
return res;
611611
}
@@ -1131,7 +1131,7 @@ mod tests {
11311131
n_satisfied: 0,
11321132
}],
11331133
age: 1002,
1134-
height: 1002,
1134+
lock_time: 1002,
11351135
has_errored: false,
11361136
}
11371137
}

0 commit comments

Comments
 (0)