pub struct Thread<'a> {Show 17 fields
pub dstack: Stack,
pub astack: Stack,
pub else_stack: BoolStack,
pub cfg: Config,
pub scripts: Vec<ParsedScript>,
pub cond_stack: Vec<i32>,
pub saved_first_stack: Vec<Vec<u8>>,
pub script_idx: usize,
pub script_off: usize,
pub last_code_sep: usize,
pub num_ops: usize,
pub flags: ScriptFlags,
pub bip16: bool,
pub after_genesis: bool,
pub early_return_after_genesis: bool,
pub tx_context: Option<&'a dyn TxContext>,
pub input_idx: usize,
}Expand description
The execution thread for the script interpreter.
Fields§
§dstack: StackThe main data stack used during script execution.
astack: StackThe alternate stack used by OP_TOALTSTACK and OP_FROMALTSTACK.
else_stack: BoolStackStack tracking nested IF/ELSE/ENDIF conditional execution state.
cfg: ConfigInterpreter configuration with pre/post-genesis limits.
scripts: Vec<ParsedScript>The parsed scripts to execute (unlocking, locking, and optionally P2SH).
cond_stack: Vec<i32>Stack of conditional execution flags for nested IF/ELSE blocks.
saved_first_stack: Vec<Vec<u8>>Saved copy of the data stack after the first (unlocking) script for BIP16.
script_idx: usizeIndex of the currently executing script in the scripts array.
script_off: usizeOffset of the currently executing opcode within the current script.
last_code_sep: usizeOffset of the most recent OP_CODESEPARATOR in the current script.
num_ops: usizeRunning count of non-push opcodes executed (checked against max_ops).
flags: ScriptFlagsActive script verification flags controlling interpreter behavior.
bip16: boolWhether BIP16 (P2SH) evaluation is active for this execution.
after_genesis: boolWhether post-genesis rules are active (relaxed limits, OP_RETURN behavior).
early_return_after_genesis: boolWhether an OP_RETURN has been encountered in post-genesis mode.
tx_context: Option<&'a dyn TxContext>Optional transaction context for signature and locktime verification.
input_idx: usizeThe transaction input index being verified.
Implementations§
Source§impl<'a> Thread<'a>
impl<'a> Thread<'a>
Sourcepub fn new(
unlocking_script: &Script,
locking_script: &Script,
flags: ScriptFlags,
tx_context: Option<&'a dyn TxContext>,
input_idx: usize,
) -> Result<Self, InterpreterError>
pub fn new( unlocking_script: &Script, locking_script: &Script, flags: ScriptFlags, tx_context: Option<&'a dyn TxContext>, input_idx: usize, ) -> Result<Self, InterpreterError>
Create a new execution thread from unlocking and locking scripts.
Validates script sizes, parses both scripts, and initializes the execution environment with the appropriate flags and configuration.
Sourcepub fn has_flag(&self, flag: ScriptFlags) -> bool
pub fn has_flag(&self, flag: ScriptFlags) -> bool
Check if a specific script verification flag is set.
Sourcepub fn has_any(&self, flags: &[ScriptFlags]) -> bool
pub fn has_any(&self, flags: &[ScriptFlags]) -> bool
Check if any of the given script verification flags are set.
Sourcepub fn is_branch_executing(&self) -> bool
pub fn is_branch_executing(&self) -> bool
Return true if the current conditional branch is executing.
Sourcepub fn should_exec(&self, pop: &ParsedOpcode) -> bool
pub fn should_exec(&self, pop: &ParsedOpcode) -> bool
Return true if the given opcode should be executed in the current state.
Sourcepub fn execute(&mut self) -> Result<(), InterpreterError>
pub fn execute(&mut self) -> Result<(), InterpreterError>
Execute all scripts.
Sourcepub fn step(&mut self) -> Result<bool, InterpreterError>
pub fn step(&mut self) -> Result<bool, InterpreterError>
Execute one step. Returns true if execution is complete.