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,
)
| 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) |
| 137 | fn 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 |
| 182 | pub fn dry_run_taproot_input( |
no test coverage detected