Encountering OP_VERIF and OP_VERNOTIF in execution is always an error.
I honestly thought we already handled this, but some tests dhill is working on shows that we didn't.
This commit is contained in:
parent
201d6651c9
commit
8df0af32d6
2 changed files with 24 additions and 1 deletions
16
opcode.go
16
opcode.go
|
@ -862,6 +862,22 @@ type parsedOpcode struct {
|
||||||
opfunc func(op parsedOpcode, s Script) error
|
opfunc func(op parsedOpcode, s Script) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The following opcodes are always illegal when passed over by the program
|
||||||
|
// counter even if in a non-executed branch. (it isn't a coincidence that they
|
||||||
|
// are conditionals).
|
||||||
|
func (pop *parsedOpcode) alwaysIllegal() bool {
|
||||||
|
switch pop.opcode.value {
|
||||||
|
case OP_VERIF:
|
||||||
|
return true
|
||||||
|
case OP_VERNOTIF:
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The following opcode are conditional and thus change the conditional
|
||||||
|
// execution stack state when passed.
|
||||||
func (pop *parsedOpcode) conditional() bool {
|
func (pop *parsedOpcode) conditional() bool {
|
||||||
switch pop.opcode.value {
|
switch pop.opcode.value {
|
||||||
case OP_IF:
|
case OP_IF:
|
||||||
|
|
|
@ -52,6 +52,11 @@ var (
|
||||||
// is encountered.
|
// is encountered.
|
||||||
StackErrReservedOpcode = errors.New("Reserved Opcode")
|
StackErrReservedOpcode = errors.New("Reserved Opcode")
|
||||||
|
|
||||||
|
// StackErrAlwaysIllegal is returned when an opcode marked as always
|
||||||
|
// illegal is encountered. Currently this is just OP_VERIF and
|
||||||
|
// OP_VERNOTIF.
|
||||||
|
StackErrAlwaysIllegal = errors.New("Always Illlegal instruction encountered")
|
||||||
|
|
||||||
// StackErrEarlyReturn is returned when OP_RETURN is executed in the
|
// StackErrEarlyReturn is returned when OP_RETURN is executed in the
|
||||||
// script.
|
// script.
|
||||||
StackErrEarlyReturn = errors.New("Script returned early")
|
StackErrEarlyReturn = errors.New("Script returned early")
|
||||||
|
@ -602,7 +607,9 @@ func (m *Script) Step() (done bool, err error) {
|
||||||
if m.condStack[0] != OpCondTrue {
|
if m.condStack[0] != OpCondTrue {
|
||||||
// some opcodes still 'activate' if on the non-executing side
|
// some opcodes still 'activate' if on the non-executing side
|
||||||
// of conditional execution
|
// of conditional execution
|
||||||
if opcode.conditional() {
|
if opcode.alwaysIllegal() {
|
||||||
|
return true, StackErrAlwaysIllegal
|
||||||
|
} else if opcode.conditional() {
|
||||||
executeInstr = true
|
executeInstr = true
|
||||||
} else {
|
} else {
|
||||||
executeInstr = false
|
executeInstr = false
|
||||||
|
|
Loading…
Reference in a new issue