Skip to content

Commit bd6ef65

Browse files
committed
interpreter: rename "age" to "sequence"
The "age" from the transaction is actually just a sequence number. Whether it is interpreted as an "age" depends on various other factors, as described in BIP112. In the next commits we will start moving much of our `Sequence` usage to `relative::LockTime` and it will be helpful to have clearer names.
1 parent 950b793 commit bd6ef65

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/interpreter/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct Interpreter<'txin> {
3535
/// For non-Taproot spends, the scriptCode; for Taproot script-spends, this
3636
/// is the leaf script; for key-spends it is `None`.
3737
script_code: Option<bitcoin::ScriptBuf>,
38-
age: Sequence,
38+
sequence: Sequence,
3939
lock_time: absolute::LockTime,
4040
}
4141

@@ -136,11 +136,11 @@ impl<'txin> Interpreter<'txin> {
136136
spk: &bitcoin::ScriptBuf,
137137
script_sig: &'txin bitcoin::Script,
138138
witness: &'txin Witness,
139-
age: Sequence, // CSV, relative lock time.
139+
sequence: Sequence, // CSV, relative lock time.
140140
lock_time: absolute::LockTime, // CLTV, absolute lock time.
141141
) -> Result<Self, Error> {
142142
let (inner, stack, script_code) = inner::from_txdata(spk, script_sig, witness)?;
143-
Ok(Interpreter { inner, stack, script_code, age, lock_time })
143+
Ok(Interpreter { inner, stack, script_code, sequence, lock_time })
144144
}
145145

146146
/// Same as [`Interpreter::iter`], but allows for a custom verification function.
@@ -165,7 +165,7 @@ impl<'txin> Interpreter<'txin> {
165165
// Cloning the references to elements of stack should be fine as it allows
166166
// call interpreter.iter() without mutating interpreter
167167
stack: self.stack.clone(),
168-
age: self.age,
168+
sequence: self.sequence,
169169
lock_time: self.lock_time,
170170
has_errored: false,
171171
sig_type: self.sig_type(),
@@ -508,7 +508,7 @@ pub struct Iter<'intp, 'txin: 'intp> {
508508
public_key: Option<&'intp BitcoinKey>,
509509
state: Vec<NodeEvaluationState<'intp>>,
510510
stack: Stack<'txin>,
511-
age: Sequence,
511+
sequence: Sequence,
512512
lock_time: absolute::LockTime,
513513
has_errored: bool,
514514
sig_type: SigType,
@@ -608,7 +608,7 @@ where
608608
Terminal::Older(ref n) => {
609609
debug_assert_eq!(node_state.n_evaluated, 0);
610610
debug_assert_eq!(node_state.n_satisfied, 0);
611-
let res = self.stack.evaluate_older(n, self.age);
611+
let res = self.stack.evaluate_older(n, self.sequence);
612612
if res.is_some() {
613613
return res;
614614
}
@@ -1110,7 +1110,7 @@ mod tests {
11101110
stack,
11111111
public_key: None,
11121112
state: vec![NodeEvaluationState { node: ms, n_evaluated: 0, n_satisfied: 0 }],
1113-
age: Sequence::from_height(1002),
1113+
sequence: Sequence::from_height(1002),
11141114
lock_time: absolute::LockTime::from_height(1002).unwrap(),
11151115
has_errored: false,
11161116
sig_type: SigType::Ecdsa,

0 commit comments

Comments
 (0)