|
|
@ -242,7 +242,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType, |
|
|
|
|
|
|
|
case Opcode.map.OP_DEPTH: |
|
|
|
// -- stacksize
|
|
|
|
var value = bignum(this.stack.length); |
|
|
|
var value = new 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 = bignum(this.stackTop().length); |
|
|
|
var value = new 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(bignum(1)); |
|
|
|
num = num.add(new bignum(1)); |
|
|
|
break; |
|
|
|
case Opcode.map.OP_1SUB: |
|
|
|
num = num.sub(bignum(1)); |
|
|
|
num = num.sub(new bignum(1)); |
|
|
|
break; |
|
|
|
case Opcode.map.OP_2MUL: |
|
|
|
num = num.mul(bignum(2)); |
|
|
|
num = num.mul(new bignum(2)); |
|
|
|
break; |
|
|
|
case Opcode.map.OP_2DIV: |
|
|
|
num = num.div(bignum(2)); |
|
|
|
num = num.div(new bignum(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 = bignum(num.cmp(0) == 0 ? 1 : 0); |
|
|
|
num = new bignum(num.cmp(new bignum(0)) == 0 ? 1 : 0); |
|
|
|
break; |
|
|
|
case Opcode.map.OP_0NOTEQUAL: |
|
|
|
num = bignum(num.cmp(0) == 0 ? 0 : 1); |
|
|
|
num = new bignum(num.cmp(new bignum(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(0) < 0 || v2.cmp(2048) > 0) { |
|
|
|
if (v2.cmp(new bignum(0)) < 0 || v2.cmp(new 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(0) < 0 || v2.cmp(2048) > 0) { |
|
|
|
if (v2.cmp(new bignum(0)) < 0 || v2.cmp(new bignum(2048)) > 0) { |
|
|
|
throw new Error("OP_RSHIFT parameter out of bounds"); |
|
|
|
} |
|
|
|
num = v1.shiftRight(v2); |
|
|
|
break; |
|
|
|
|
|
|
|
case Opcode.map.OP_BOOLAND: |
|
|
|
num = bignum((v1.cmp(0) != 0 && v2.cmp(0) != 0) ? 1 : 0); |
|
|
|
num = new bignum((v1.cmp(new bignum(0)) != 0 && v2.cmp(new bignum(0)) != 0) ? 1 : 0); |
|
|
|
break; |
|
|
|
|
|
|
|
case Opcode.map.OP_BOOLOR: |
|
|
|
num = bignum((v1.cmp(0) != 0 || v2.cmp(0) != 0) ? 1 : 0); |
|
|
|
num = new bignum((v1.cmp(new bignum(0)) != 0 || v2.cmp(new bignum(0)) != 0) ? 1 : 0); |
|
|
|
break; |
|
|
|
|
|
|
|
case Opcode.map.OP_NUMEQUAL: |
|
|
|
case Opcode.map.OP_NUMEQUALVERIFY: |
|
|
|
num = bignum(v1.cmp(v2) == 0 ? 1 : 0); |
|
|
|
num = new bignum(v1.cmp(v2) == 0 ? 1 : 0); |
|
|
|
break; |
|
|
|
|
|
|
|
case Opcode.map.OP_NUMNOTEQUAL: |
|
|
|
; |
|
|
|
num = bignum(v1.cmp(v2) != 0 ? 1 : 0); |
|
|
|
num = new bignum(v1.cmp(v2) != 0 ? 1 : 0); |
|
|
|
break; |
|
|
|
|
|
|
|
case Opcode.map.OP_LESSTHAN: |
|
|
|
num = bignum(v1.lt(v2) ? 1 : 0); |
|
|
|
num = new bignum(v1.lt(v2) ? 1 : 0); |
|
|
|
break; |
|
|
|
|
|
|
|
case Opcode.map.OP_GREATERTHAN: |
|
|
|
num = bignum(v1.gt(v2) ? 1 : 0); |
|
|
|
num = new bignum(v1.gt(v2) ? 1 : 0); |
|
|
|
break; |
|
|
|
|
|
|
|
case Opcode.map.OP_LESSTHANOREQUAL: |
|
|
|
num = bignum(v1.gt(v2) ? 0 : 1); |
|
|
|
num = new bignum(v1.gt(v2) ? 0 : 1); |
|
|
|
break; |
|
|
|
|
|
|
|
case Opcode.map.OP_GREATERTHANOREQUAL: |
|
|
|
num = bignum(v1.lt(v2) ? 0 : 1); |
|
|
|
num = new 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(-128) >= 0 && num.cmp(127) <= 0) { |
|
|
|
if (num.cmp(new bignum(-128)) >= 0 && num.cmp(new bignum(127)) <= 0) { |
|
|
|
return num.toNumber(); |
|
|
|
} else { |
|
|
|
return buffertools.toHex(chunk.slice(0)); |
|
|
|