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

Function IsPushOnlyScript

txscript/script.go:133–146  ·  view source on GitHub ↗

IsPushOnlyScript returns whether or not the passed script only pushes data according to the consensus definition of pushing data. WARNING: This function always treats the passed script as version 0. Great care must be taken if introducing a new script version because it is used in consensus which,

(script []byte)

Source from the content-addressed store, hash-verified

131// script versions before checking if it is a push only script which means nodes
132// on existing rules will treat new version scripts as if they were version 0.
133func IsPushOnlyScript(script []byte) bool {
134 const scriptVersion = 0
135 tokenizer := MakeScriptTokenizer(scriptVersion, script)
136 for tokenizer.Next() {
137 // All opcodes up to OP_16 are data push instructions.
138 // NOTE: This does consider OP_RESERVED to be a data push instruction,
139 // but execution of OP_RESERVED will fail anyway and matches the
140 // behavior required by consensus.
141 if tokenizer.Opcode() > OP_16 {
142 return false
143 }
144 }
145 return tokenizer.Err() == nil
146}
147
148// DisasmString formats a disassembled script for one line printing. When the
149// script fails to parse, the returned string will contain the disassembled

Callers 9

buildWitnessProgramMethod · 0.85
NewEngineFunction · 0.85
GetPreciseSigOpCountFunction · 0.85
GetWitnessSigOpCountFunction · 0.85
TestHasCanonicalPushFunction · 0.85
TestIsPushOnlyScriptFunction · 0.85
CalcScriptInfoFunction · 0.85

Calls 4

MakeScriptTokenizerFunction · 0.85
OpcodeMethod · 0.80
ErrMethod · 0.80
NextMethod · 0.65

Tested by 3

TestHasCanonicalPushFunction · 0.68
TestIsPushOnlyScriptFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…