DisasmScript returns the disassembly string for the script at the requested offset index. Index 0 is the signature script and 1 is the public key script. In the case of pay-to-script-hash, index 2 is the redeem script once the execution has progressed far enough to have successfully verified scrip
(idx int)
| 903 | // the execution has progressed far enough to have successfully verified script |
| 904 | // hash and thus add the script to the scripts to execute. |
| 905 | func (vm *Engine) DisasmScript(idx int) (string, error) { |
| 906 | if idx >= len(vm.scripts) { |
| 907 | str := fmt.Sprintf("script index %d >= total scripts %d", idx, |
| 908 | len(vm.scripts)) |
| 909 | return "", scriptError(ErrInvalidIndex, str) |
| 910 | } |
| 911 | |
| 912 | var disbuf strings.Builder |
| 913 | script := vm.scripts[idx] |
| 914 | tokenizer := MakeScriptTokenizer(vm.version, script) |
| 915 | var opcodeIdx int |
| 916 | for tokenizer.Next() { |
| 917 | disbuf.WriteString(fmt.Sprintf("%02x:%04x: ", idx, opcodeIdx)) |
| 918 | disasmOpcode(&disbuf, tokenizer.op, tokenizer.Data(), false) |
| 919 | disbuf.WriteByte('\n') |
| 920 | opcodeIdx++ |
| 921 | } |
| 922 | return disbuf.String(), tokenizer.Err() |
| 923 | } |
| 924 | |
| 925 | // CheckErrorCondition returns nil if the running script has ended and was |
| 926 | // successful, leaving a a true boolean on the stack. An error otherwise, |
no test coverage detected