MCPcopy Index your code
hub / github.com/BitVM/BitVM / execute_script_buf_optional_stack_limit

Function execute_script_buf_optional_stack_limit

bitvm/src/lib.rs:137–179  ·  view source on GitHub ↗

Executing a script on stack without `MAX_STACK_SIZE` limit is only for testing purposes \ Don't use in production without the stack limit (i.e. `stack_limit` set to false)

(
    script: bitcoin::ScriptBuf,
    stack_limit: bool,
)

Source from the content-addressed store, hash-verified

135/// Executing a script on stack without `MAX_STACK_SIZE` limit is only for testing purposes \
136/// Don't use in production without the stack limit (i.e. `stack_limit` set to false)
137fn execute_script_buf_optional_stack_limit(
138 script: bitcoin::ScriptBuf,
139 stack_limit: bool,
140) -> ExecuteInfo {
141 let opts = Options {
142 enforce_stack_limit: stack_limit,
143 ..Default::default()
144 };
145 let mut exec = Exec::new(
146 ExecCtx::Tapscript,
147 opts,
148 TxTemplate {
149 tx: Transaction {
150 version: bitcoin::transaction::Version::TWO,
151 lock_time: bitcoin::locktime::absolute::LockTime::ZERO,
152 input: vec![],
153 output: vec![],
154 },
155 prevouts: vec![],
156 input_idx: 0,
157 taproot_annex_scriptleaf: Some((TapLeafHash::all_zeros(), None)),
158 },
159 script,
160 vec![],
161 )
162 .expect("error creating exec");
163
164 loop {
165 if exec.exec_next().is_err() {
166 break;
167 }
168 }
169
170 let res = exec.result().unwrap();
171 ExecuteInfo {
172 success: res.success,
173 error: res.error.clone(),
174 last_opcode: res.opcode,
175 final_stack: FmtStack(exec.stack().clone()),
176 remaining_script: exec.remaining_script().to_asm_string(),
177 stats: exec.stats().clone(),
178 }
179}
180
181/// Dry-runs a specific taproot input
182pub fn dry_run_taproot_input(

Callers 4

execute_scriptFunction · 0.85
execute_script_bufFunction · 0.85

Calls 2

FmtStackClass · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected