pub fn eval_script(
script: &[u8],
stack: &mut Vec<StackElement>,
flags: u32,
sigversion: SigVersion,
) -> Result<bool>Expand description
EvalScript: 𝒮𝒞 × 𝒮𝒯 × ℕ × SigVersion → {true, false}
Script execution follows a stack-based virtual machine:
- Initialize stack S = ∅
- For each opcode op in script:
- If |S| > L_stack: return false (stack overflow)
- If operation count > L_ops: return false (operation limit exceeded)
- Execute op with current stack state
- If execution fails: return false
- Return |S| = 1 ∧ S[0] ≠ 0 (exactly one non-zero value on stack)
Performance: Pre-allocates stack with capacity hint to reduce allocations
In production mode, stacks should be obtained from pool using get_pooled_stack()
for optimal performance. This function works with any Vec