Skip to content

Commit fcc1cc5

Browse files
tchardingsanket1729
authored andcommitted
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 39f0edf commit fcc1cc5

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
@@ -170,16 +170,16 @@ impl<'txin> Interpreter<'txin> {
170170
spk: &bitcoin::Script,
171171
script_sig: &'txin bitcoin::Script,
172172
witness: &'txin Witness,
173-
age: u32, // CSV, relative lock time.
174-
height: u32, // CLTV, absolute lock time.
173+
age: u32, // CSV, relative lock time.
174+
lock_time: u32, // CLTV, absolute lock time.
175175
) -> Result<Self, Error> {
176176
let (inner, stack, script_code) = inner::from_txdata(spk, script_sig, witness)?;
177177
Ok(Interpreter {
178178
inner,
179179
stack,
180180
script_code,
181181
age,
182-
height,
182+
lock_time,
183183
})
184184
}
185185

@@ -210,7 +210,7 @@ impl<'txin> Interpreter<'txin> {
210210
// call interpreter.iter() without mutating interpreter
211211
stack: self.stack.clone(),
212212
age: self.age,
213-
height: self.height,
213+
lock_time: self.lock_time,
214214
has_errored: false,
215215
}
216216
}
@@ -529,7 +529,7 @@ pub struct Iter<'intp, 'txin: 'intp> {
529529
state: Vec<NodeEvaluationState<'intp>>,
530530
stack: Stack<'txin>,
531531
age: u32,
532-
height: u32,
532+
lock_time: u32,
533533
has_errored: bool,
534534
}
535535

@@ -606,7 +606,7 @@ where
606606
Terminal::After(ref n) => {
607607
debug_assert_eq!(node_state.n_evaluated, 0);
608608
debug_assert_eq!(node_state.n_satisfied, 0);
609-
let res = self.stack.evaluate_after(n, self.height);
609+
let res = self.stack.evaluate_after(n, self.lock_time);
610610
if res.is_some() {
611611
return res;
612612
}
@@ -1132,7 +1132,7 @@ mod tests {
11321132
n_satisfied: 0,
11331133
}],
11341134
age: 1002,
1135-
height: 1002,
1135+
lock_time: 1002,
11361136
has_errored: false,
11371137
}
11381138
}

0 commit comments

Comments
 (0)