Skip to content

Commit a6b9eb4

Browse files
apoelstrasanket1729
authored andcommitted
comments: clean up the comments around the "scriptcode" hack in Interpreter
1 parent 10beaa5 commit a6b9eb4

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/interpreter/inner.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,12 @@ pub(super) fn from_txdata<'txin>(
244244
Ok((
245245
Inner::Script(ms, ScriptType::Tr),
246246
wit_stack,
247-
// Tr script spend code is stored in script spend. This is an internal hack to store the
248-
// encoded script instead yet another tagged enum for saving tap_script
249-
// We can recompute the script again by translating from nochecks to tap and re-encoding it
250-
// Having this hack seems simple because this is not exposed publicly and the internal code is
251-
// easy to audit
247+
// Tapscript is returned as a "scriptcode". This is a hack, but avoids adding yet
248+
// another enum just for taproot, and this function is not a publicly exposed API,
249+
// so it's easy enough to keep track of all uses.
250+
//
251+
// In particular, this return value will be put into the `script_code` member of
252+
// the `Interpreter` script; the iterpreter logic does the right thing with it.
252253
Some(tap_script),
253254
))
254255
} else {

src/interpreter/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ use self::stack::Stack;
4646
pub struct Interpreter<'txin> {
4747
inner: inner::Inner,
4848
stack: Stack<'txin>,
49-
script_code: Option<bitcoin::Script>, // taproot transactions don't have script code
49+
/// For non-Taproot spends, the scriptCode; for Taproot script-spends, this
50+
/// is the leaf script; for key-spends it is `None`.
51+
script_code: Option<bitcoin::Script>,
5052
age: u32,
5153
height: u32,
5254
}

0 commit comments

Comments
 (0)