script: remove disabled opcode code.

This commit is contained in:
Christopher Jeffrey 2017-06-10 01:27:19 -07:00
parent 30b8a458ed
commit 3fd229d9ee
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -658,7 +658,10 @@ Script.prototype.execute = function execute(stack, flags, tx, index, value, vers
stack.push(STACK_NEGATE);
break;
}
case opcodes.OP_1:
case opcodes.OP_1: {
stack.push(STACK_TRUE);
break;
}
case opcodes.OP_2:
case opcodes.OP_3:
case opcodes.OP_4:
@ -973,10 +976,10 @@ Script.prototype.execute = function execute(stack, flags, tx, index, value, vers
num.isubn(1);
break;
case opcodes.OP_2MUL:
num.iushln(1);
assert(false);
break;
case opcodes.OP_2DIV:
num.iushrn(1);
assert(false);
break;
case opcodes.OP_NEGATE:
num.ineg();
@ -1029,31 +1032,25 @@ Script.prototype.execute = function execute(stack, flags, tx, index, value, vers
switch (op) {
case opcodes.OP_ADD:
num = n1.add(n2);
num = n1.iadd(n2);
break;
case opcodes.OP_SUB:
num = n1.sub(n2);
num = n1.isub(n2);
break;
case opcodes.OP_MUL:
num = n1.mul(n2);
assert(false);
break;
case opcodes.OP_DIV:
num = n1.div(n2);
assert(false);
break;
case opcodes.OP_MOD:
num = n1.mod(n2);
assert(false);
break;
case opcodes.OP_LSHIFT:
if (n2.cmpn(0) < 0 || n2.cmpn(2048) > 0)
throw new ScriptError('UNKNOWN_ERROR', 'Bad shift.');
num = n1.ushln(n2.toNumber());
asssert(false);
break;
case opcodes.OP_RSHIFT:
if (n2.cmpn(0) < 0 || n2.cmpn(2048) > 0)
throw new ScriptError('UNKNOWN_ERROR', 'Bad shift.');
num = n1.ushrn(n2.toNumber());
assert(false);
break;
case opcodes.OP_BOOLAND:
num = n1.cmpn(0) !== 0 && n2.cmpn(0) !== 0;
@ -1317,115 +1314,26 @@ Script.prototype.execute = function execute(stack, flags, tx, index, value, vers
break;
}
case opcodes.OP_CAT: {
if (stack.length < 2)
throw new ScriptError('INVALID_STACK_OPERATION', op, ip);
v1 = stack.top(-2);
v2 = stack.top(-1);
stack.set(-2, util.concat(v1, v2));
stack.pop();
assert(false);
break;
}
case opcodes.OP_SUBSTR: {
if (stack.length < 3)
throw new ScriptError('INVALID_STACK_OPERATION', op, ip);
v1 = stack.top(-3);
v2 = Script.num(stack.top(-2), minimal).toNumber();
v3 = Script.num(stack.top(-1), minimal).toNumber();
if (v2 < 0 || v3 < v2)
throw new ScriptError('UNKNOWN_ERROR', 'String out of range.');
if (v2 > v1.length)
v2 = v1.length;
if (v3 > v1.length)
v3 = v1.length;
stack.set(-3, v1.slice(v2, v3));
stack.pop();
stack.pop();
assert(false);
break;
}
case opcodes.OP_LEFT:
case opcodes.OP_RIGHT: {
if (stack.length < 2)
throw new ScriptError('INVALID_STACK_OPERATION', op, ip);
v1 = stack.top(-2);
v2 = Script.num(stack.top(-1), minimal).toNumber();
if (v2 < 0)
throw new ScriptError('UNKNOWN_ERROR', 'String size out of range.');
if (v2 > v1.length)
v2 = v1.length;
if (op === opcodes.OP_LEFT)
v1 = v1.slice(0, v2);
else
v1 = v1.slice(v1.length - v2);
stack.set(-2, v1);
stack.pop();
assert(false);
break;
}
case opcodes.OP_INVERT: {
if (stack.length < 1)
throw new ScriptError('INVALID_STACK_OPERATION', op, ip);
val = util.copy(stack.top(-1));
stack.set(-1, val);
for (i = 0; i < val.length; i++)
val[i] = ~val[i] & 0xff;
assert(false);
break;
}
case opcodes.OP_AND:
case opcodes.OP_OR:
case opcodes.OP_XOR: {
if (stack.length < 2)
throw new ScriptError('INVALID_STACK_OPERATION', op, ip);
v1 = util.copy(stack.top(-2));
v2 = stack.top(-1);
if (v1.length < v2.length) {
v3 = Buffer.allocUnsafe(v2.length);
v3.fill(0);
v1.copy(v3, 0);
v1 = v3;
}
if (v2.length < v1.length) {
v3 = Buffer.allocUnsafe(v1.length);
v3.fill(0);
v2.copy(v3, 0);
v2 = v3;
}
stack.set(-2, v1);
if (op === opcodes.OP_AND) {
for (i = 0; i < v1.length; i++)
v1[i] &= v2[i];
} else if (op === opcodes.OP_OR) {
for (i = 0; i < v1.length; i++)
v1[i] |= v2[i];
} else if (op === opcodes.OP_XOR) {
for (i = 0; i < v1.length; i++)
v1[i] ^= v2[i];
}
stack.pop();
assert(false);
break;
}
default: {