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)
| 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. |
| 133 | func 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 |
searching dependent graphs…