diff --git a/lib/ScriptInterpreter.js b/lib/ScriptInterpreter.js index db131da28..a22c29e68 100644 --- a/lib/ScriptInterpreter.js +++ b/lib/ScriptInterpreter.js @@ -242,7 +242,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType, case Opcode.map.OP_DEPTH: // -- stacksize - var value = new bignum(this.stack.length); + var value = bignum(this.stack.length); this.stack.push(intToBufferSM(value)); break; @@ -351,7 +351,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType, case Opcode.map.OP_SIZE: // (in -- in size) - var value = new bignum(this.stackTop().length); + var value = bignum(this.stackTop().length); this.stack.push(intToBufferSM(value)); break; @@ -427,16 +427,16 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType, var num = bufferSMToInt(this.stackTop()); switch (opcode) { case Opcode.map.OP_1ADD: - num = num.add(new bignum(1)); + num = num.add(1); break; case Opcode.map.OP_1SUB: - num = num.sub(new bignum(1)); + num = num.sub(1); break; case Opcode.map.OP_2MUL: - num = num.mul(new bignum(2)); + num = num.mul(2); break; case Opcode.map.OP_2DIV: - num = num.div(new bignum(2)); + num = num.div(2); break; case Opcode.map.OP_NEGATE: num = num.neg(); @@ -445,10 +445,10 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType, num = num.abs(); break; case Opcode.map.OP_NOT: - num = new bignum(num.cmp(new bignum(0)) == 0 ? 1 : 0); + num = bignum(num.cmp(0) == 0 ? 1 : 0); break; case Opcode.map.OP_0NOTEQUAL: - num = new bignum(num.cmp(new bignum(0)) == 0 ? 0 : 1); + num = bignum(num.cmp(0) == 0 ? 0 : 1); break; } this.stack[this.stack.length - 1] = intToBufferSM(num); @@ -494,51 +494,51 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType, break; case Opcode.map.OP_LSHIFT: - if (v2.cmp(new bignum(0)) < 0 || v2.cmp(new bignum(2048)) > 0) { + if (v2.cmp(0) < 0 || v2.cmp(bignum(2048)) > 0) { throw new Error("OP_LSHIFT parameter out of bounds"); } num = v1.shiftLeft(v2); break; case Opcode.map.OP_RSHIFT: - if (v2.cmp(new bignum(0)) < 0 || v2.cmp(new bignum(2048)) > 0) { + if (v2.cmp(0) < 0 || v2.cmp(bignum(2048)) > 0) { throw new Error("OP_RSHIFT parameter out of bounds"); } num = v1.shiftRight(v2); break; case Opcode.map.OP_BOOLAND: - num = new bignum((v1.cmp(new bignum(0)) != 0 && v2.cmp(new bignum(0)) != 0) ? 1 : 0); + num = bignum((v1.cmp(0) != 0 && v2.cmp(0) != 0) ? 1 : 0); break; case Opcode.map.OP_BOOLOR: - num = new bignum((v1.cmp(new bignum(0)) != 0 || v2.cmp(new bignum(0)) != 0) ? 1 : 0); + num = bignum((v1.cmp(0) != 0 || v2.cmp(0) != 0) ? 1 : 0); break; case Opcode.map.OP_NUMEQUAL: case Opcode.map.OP_NUMEQUALVERIFY: - num = new bignum(v1.cmp(v2) == 0 ? 1 : 0); + num = bignum(v1.cmp(v2) == 0 ? 1 : 0); break; case Opcode.map.OP_NUMNOTEQUAL: ; - num = new bignum(v1.cmp(v2) != 0 ? 1 : 0); + num = bignum(v1.cmp(v2) != 0 ? 1 : 0); break; case Opcode.map.OP_LESSTHAN: - num = new bignum(v1.lt(v2) ? 1 : 0); + num = bignum(v1.lt(v2) ? 1 : 0); break; case Opcode.map.OP_GREATERTHAN: - num = new bignum(v1.gt(v2) ? 1 : 0); + num = bignum(v1.gt(v2) ? 1 : 0); break; case Opcode.map.OP_LESSTHANOREQUAL: - num = new bignum(v1.gt(v2) ? 0 : 1); + num = bignum(v1.gt(v2) ? 0 : 1); break; case Opcode.map.OP_GREATERTHANOREQUAL: - num = new bignum(v1.lt(v2) ? 0 : 1); + num = bignum(v1.lt(v2) ? 0 : 1); break; case Opcode.map.OP_MIN: @@ -835,7 +835,7 @@ ScriptInterpreter.prototype.getPrimitiveStack = function getPrimitiveStack() { return buffertools.toHex(chunk.slice(0)); } var num = bufferSMToInt(chunk); - if (num.cmp(new bignum(-128)) >= 0 && num.cmp(new bignum(127)) <= 0) { + if (num.cmp(-128) >= 0 && num.cmp(127) <= 0) { return num.toNumber(); } else { return buffertools.toHex(chunk.slice(0));