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

Function dry_run_taproots

bitvm/src/lib.rs:245–261  ·  view source on GitHub ↗

Dry-runs all taproot input scripts. Return Ok(()) if all scripts execute successfully, or Err((input_index, ExecuteInfo)) otherwise

(tx: &Transaction, prevouts: &[TxOut])

Source from the content-addressed store, hash-verified

243/// Dry-runs all taproot input scripts. Return Ok(()) if all scripts execute successfully,
244/// or Err((input_index, ExecuteInfo)) otherwise
245pub fn dry_run_taproots(tx: &Transaction, prevouts: &[TxOut]) -> Result<(), ExecuteInfo> {
246 let taproot_indices = prevouts
247 .iter()
248 .enumerate()
249 .filter(|(_, prevout)| prevout.script_pubkey.as_script().is_p2tr()) // only taproots
250 .filter(|(idx, _)| tx.input[*idx].witness.tapscript().is_some()) // only script path spends
251 .map(|(idx, _)| idx);
252
253 for taproot_index in taproot_indices {
254 let result = dry_run_taproot_input(tx, taproot_index, prevouts);
255 if !result.success {
256 return Err(result);
257 }
258 }
259
260 Ok(())
261}
262
263pub fn run(script: treepp::Script) {
264 // let stack = script.clone().analyze_stack();

Callers

nothing calls this directly

Calls 1

dry_run_taproot_inputFunction · 0.85

Tested by

no test coverage detected