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

Function DisasmString

txscript/script.go:157–176  ·  view source on GitHub ↗

DisasmString formats a disassembled script for one line printing. When the script fails to parse, the returned string will contain the disassembled script up to the point the failure occurred along with the string '[error]' appended. In addition, the reason the script failed to parse is returned i

(script []byte)

Source from the content-addressed store, hash-verified

155// does not accept a script version, the results are undefined for other script
156// versions.
157func DisasmString(script []byte) (string, error) {
158 const scriptVersion = 0
159
160 var disbuf strings.Builder
161 tokenizer := MakeScriptTokenizer(scriptVersion, script)
162 if tokenizer.Next() {
163 disasmOpcode(&disbuf, tokenizer.op, tokenizer.Data(), true)
164 }
165 for tokenizer.Next() {
166 disbuf.WriteByte(' ')
167 disasmOpcode(&disbuf, tokenizer.op, tokenizer.Data(), true)
168 }
169 if tokenizer.Err() != nil {
170 if tokenizer.ByteIndex() != 0 {
171 disbuf.WriteByte(' ')
172 }
173 disbuf.WriteString("[error]")
174 }
175 return disbuf.String(), tokenizer.Err()
176}
177
178// removeOpcodeRaw will return the script after removing any opcodes that match
179// `opcode`. If the opcode does not appear in script, the original script will

Callers 5

BenchmarkDisasmStringFunction · 0.85
TestScriptTemplateFunction · 0.85
ExampleScriptTemplateFunction · 0.85
StringMethod · 0.85

Calls 7

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

Tested by 3

BenchmarkDisasmStringFunction · 0.68
TestScriptTemplateFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…