MCPcopy Index your code
hub / github.com/btcsuite/btcd / DisasmScript

Method DisasmScript

txscript/engine.go:905–923  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

903// the execution has progressed far enough to have successfully verified script
904// hash and thus add the script to the scripts to execute.
905func (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,

Callers 1

CheckErrorConditionMethod · 0.95

Calls 7

scriptErrorFunction · 0.85
MakeScriptTokenizerFunction · 0.85
disasmOpcodeFunction · 0.85
DataMethod · 0.80
ErrMethod · 0.80
NextMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected