branch state.

This commit is contained in:
Christopher Jeffrey 2016-06-16 02:25:42 -07:00
parent 51f3d7120b
commit 36fc40ee7c
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1271,11 +1271,11 @@ Script.prototype.execute = function execute(stack, flags, tx, index, version) {
val = Script.bool(stack.pop()); val = Script.bool(stack.pop());
if (op === opcodes.OP_NOTIF) if (op === opcodes.OP_NOTIF)
val = !val; val = !val;
state.push(val === true ? 1 : 0); state.push(val);
if (!val) if (!val)
negate++; negate++;
} else { } else {
state.push(0); state.push(false);
negate++; negate++;
} }
break; break;
@ -1283,8 +1283,8 @@ Script.prototype.execute = function execute(stack, flags, tx, index, version) {
case opcodes.OP_ELSE: { case opcodes.OP_ELSE: {
if (state.length === 0) if (state.length === 0)
throw new ScriptError('UNBALANCED_CONDITIONAL', op, ip); throw new ScriptError('UNBALANCED_CONDITIONAL', op, ip);
state[state.length - 1] ^= 1; state[state.length - 1] = !state[state.length - 1];
if (state[state.length - 1] === 0) if (!state[state.length - 1])
negate++; negate++;
else else
negate--; negate--;
@ -1293,7 +1293,7 @@ Script.prototype.execute = function execute(stack, flags, tx, index, version) {
case opcodes.OP_ENDIF: { case opcodes.OP_ENDIF: {
if (state.length === 0) if (state.length === 0)
throw new ScriptError('UNBALANCED_CONDITIONAL', op, ip); throw new ScriptError('UNBALANCED_CONDITIONAL', op, ip);
if (state.pop() === 0) if (!state.pop())
negate--; negate--;
break; break;
} }