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