more refactoring.
This commit is contained in:
parent
36fc40ee7c
commit
5008a5880c
@ -1265,19 +1265,17 @@ Script.prototype.execute = function execute(stack, flags, tx, index, version) {
|
|||||||
switch (op) {
|
switch (op) {
|
||||||
case opcodes.OP_IF:
|
case opcodes.OP_IF:
|
||||||
case opcodes.OP_NOTIF: {
|
case opcodes.OP_NOTIF: {
|
||||||
|
val = false;
|
||||||
if (negate === 0) {
|
if (negate === 0) {
|
||||||
if (stack.length < 1)
|
if (stack.length < 1)
|
||||||
throw new ScriptError('UNBALANCED_CONDITIONAL', op, ip);
|
throw new ScriptError('UNBALANCED_CONDITIONAL', op, ip);
|
||||||
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);
|
|
||||||
if (!val)
|
|
||||||
negate++;
|
|
||||||
} else {
|
|
||||||
state.push(false);
|
|
||||||
negate++;
|
|
||||||
}
|
}
|
||||||
|
state.push(val);
|
||||||
|
if (!val)
|
||||||
|
negate++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case opcodes.OP_ELSE: {
|
case opcodes.OP_ELSE: {
|
||||||
@ -1302,7 +1300,7 @@ Script.prototype.execute = function execute(stack, flags, tx, index, version) {
|
|||||||
throw new ScriptError('BAD_OPCODE', op, ip);
|
throw new ScriptError('BAD_OPCODE', op, ip);
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
assert.fatal(false, 'Fatal script error.');
|
assert(false, 'Fatal script error.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -1550,7 +1548,7 @@ Script.prototype.execute = function execute(stack, flags, tx, index, version) {
|
|||||||
n = n.cmpn(0) !== 0;
|
n = n.cmpn(0) !== 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert.fatal(false, 'Fatal script error.');
|
assert(false, 'Fatal script error.');
|
||||||
}
|
}
|
||||||
if (typeof n === 'boolean')
|
if (typeof n === 'boolean')
|
||||||
n = new bn(n ? 1 : 0);
|
n = new bn(n ? 1 : 0);
|
||||||
@ -1659,7 +1657,7 @@ Script.prototype.execute = function execute(stack, flags, tx, index, version) {
|
|||||||
n = n1.cmp(n2) > 0 ? n1 : n2;
|
n = n1.cmp(n2) > 0 ? n1 : n2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert.fatal(false, 'Fatal script error.');
|
assert(false, 'Fatal script error.');
|
||||||
}
|
}
|
||||||
if (typeof n === 'boolean')
|
if (typeof n === 'boolean')
|
||||||
n = new bn(n ? 1 : 0);
|
n = new bn(n ? 1 : 0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user