@ -14,11 +14,6 @@ var SIGHASH_NONE = 2;
var SIGHASH_SINGLE = 3 ;
var SIGHASH_ANYONECANPAY = 80 ;
// Make opcodes available as pseudo-constants
for ( var i in Opcode . map ) {
eval ( i + " = " + Opcode . map [ i ] + ";" ) ;
}
var intToBufferSM = Util . intToBufferSM
var bufferSMToInt = Util . bufferSMToInt ;
@ -74,101 +69,101 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
throw new Error ( "Max push value size exceeded (>520)" ) ;
}
if ( opcode > OP_16 && ++ opCount > 201 ) {
if ( opcode > Opcode . map . O P_16 && ++ opCount > 201 ) {
throw new Error ( "Opcode limit exceeded (>200)" ) ;
}
if ( this . disableUnsafeOpcodes &&
"number" === typeof opcode &&
( opcode === OP_CAT ||
opcode === OP_SUBSTR ||
opcode === OP_LEFT ||
opcode === OP_RIGHT ||
opcode === OP_INVERT ||
opcode === OP_AND ||
opcode === OP_OR ||
opcode === OP_XOR ||
opcode === OP_2MUL ||
opcode === OP_2DIV ||
opcode === OP_MUL ||
opcode === OP_DIV ||
opcode === OP_MOD ||
opcode === OP_LSHIFT ||
opcode === OP_RSHIFT ) ) {
( opcode === Opcode . map . O P_CAT ||
opcode === Opcode . map . O P_SUBSTR ||
opcode === Opcode . map . O P_LEFT ||
opcode === Opcode . map . O P_RIGHT ||
opcode === Opcode . map . O P_INVERT ||
opcode === Opcode . map . O P_AND ||
opcode === Opcode . map . O P_OR ||
opcode === Opcode . map . O P_XOR ||
opcode === Opcode . map . O P_2MUL ||
opcode === Opcode . map . O P_2DIV ||
opcode === Opcode . map . O P_MUL ||
opcode === Opcode . map . O P_DIV ||
opcode === Opcode . map . O P_MOD ||
opcode === Opcode . map . O P_LSHIFT ||
opcode === Opcode . map . O P_RSHIFT ) ) {
throw new Error ( "Encountered a disabled opcode" ) ;
}
if ( exec && Buffer . isBuffer ( opcode ) ) {
this . stack . push ( opcode ) ;
} else if ( exec || ( OP_IF <= opcode && opcode <= OP_ENDIF ) )
} else if ( exec || ( Opcode . map . O P_IF <= opcode && opcode <= Opcode . map . OP_ENDIF ) )
switch ( opcode ) {
case OP_0 :
case Opcode . map . O P_0 :
this . stack . push ( new Buffer ( [ ] ) ) ;
break ;
case OP_1NEGATE :
case OP_1 :
case OP_2 :
case OP_3 :
case OP_4 :
case OP_5 :
case OP_6 :
case OP_7 :
case OP_8 :
case OP_9 :
case OP_10 :
case OP_11 :
case OP_12 :
case OP_13 :
case OP_14 :
case OP_15 :
case OP_16 :
var opint = opcode - OP_1 + 1 ;
case Opcode . map . O P_1NEGATE :
case Opcode . map . O P_1 :
case Opcode . map . O P_2 :
case Opcode . map . O P_3 :
case Opcode . map . O P_4 :
case Opcode . map . O P_5 :
case Opcode . map . O P_6 :
case Opcode . map . O P_7 :
case Opcode . map . O P_8 :
case Opcode . map . O P_9 :
case Opcode . map . O P_10 :
case Opcode . map . O P_11 :
case Opcode . map . O P_12 :
case Opcode . map . O P_13 :
case Opcode . map . O P_14 :
case Opcode . map . O P_15 :
case Opcode . map . O P_16 :
var opint = opcode - Opcode . map . O P_1 + 1 ;
var opbuf = intToBufferSM ( opint ) ;
this . stack . push ( opbuf ) ;
break ;
case OP_NOP :
case OP_NOP1 :
case OP_NOP2 :
case OP_NOP3 :
case OP_NOP4 :
case OP_NOP5 :
case OP_NOP6 :
case OP_NOP7 :
case OP_NOP8 :
case OP_NOP9 :
case OP_NOP10 :
case Opcode . map . O P_NOP :
case Opcode . map . O P_NOP1 :
case Opcode . map . O P_NOP2 :
case Opcode . map . O P_NOP3 :
case Opcode . map . O P_NOP4 :
case Opcode . map . O P_NOP5 :
case Opcode . map . O P_NOP6 :
case Opcode . map . O P_NOP7 :
case Opcode . map . O P_NOP8 :
case Opcode . map . O P_NOP9 :
case Opcode . map . O P_NOP10 :
break ;
case OP_IF :
case OP_NOTIF :
case Opcode . map . O P_IF :
case Opcode . map . O P_NOTIF :
// <expression> if [statements] [else [statements]] endif
var value = false ;
if ( exec ) {
value = castBool ( this . stackPop ( ) ) ;
if ( opcode === OP_NOTIF ) {
if ( opcode === Opcode . map . O P_NOTIF ) {
value = ! value ;
}
}
execStack . push ( value ) ;
break ;
case OP_ELSE :
case Opcode . map . O P_ELSE :
if ( execStack . length < 1 ) {
throw new Error ( "Unmatched OP_ELSE" ) ;
}
execStack [ execStack . length - 1 ] = ! execStack [ execStack . length - 1 ] ;
break ;
case OP_ENDIF :
case Opcode . map . O P_ENDIF :
if ( execStack . length < 1 ) {
throw new Error ( "Unmatched OP_ENDIF" ) ;
}
execStack . pop ( ) ;
break ;
case OP_VERIFY :
case Opcode . map . O P_VERIFY :
var value = castBool ( this . stackTop ( ) ) ;
if ( value ) {
this . stackPop ( ) ;
@ -177,27 +172,27 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
}
break ;
case OP_RETURN :
case Opcode . map . O P_RETURN :
throw new Error ( "OP_RETURN" ) ;
case OP_TOALTSTACK :
case Opcode . map . O P_TOALTSTACK :
altStack . push ( this . stackPop ( ) ) ;
break ;
case OP_FROMALTSTACK :
case Opcode . map . O P_FROMALTSTACK :
if ( altStack . length < 1 ) {
throw new Error ( "OP_FROMALTSTACK with alt stack empty" ) ;
}
this . stack . push ( altStack . pop ( ) ) ;
break ;
case OP_2DROP :
case Opcode . map . O P_2DROP :
// (x1 x2 -- )
this . stackPop ( ) ;
this . stackPop ( ) ;
break ;
case OP_2DUP :
case Opcode . map . O P_2DUP :
// (x1 x2 -- x1 x2 x1 x2)
var v1 = this . stackTop ( 2 ) ;
var v2 = this . stackTop ( 1 ) ;
@ -205,7 +200,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack . push ( v2 ) ;
break ;
case OP_3DUP :
case Opcode . map . O P_3DUP :
// (x1 x2 -- x1 x2 x1 x2)
var v1 = this . stackTop ( 3 ) ;
var v2 = this . stackTop ( 2 ) ;
@ -215,7 +210,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack . push ( v3 ) ;
break ;
case OP_2OVER :
case Opcode . map . O P_2OVER :
// (x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2)
var v1 = this . stackTop ( 4 ) ;
var v2 = this . stackTop ( 3 ) ;
@ -223,7 +218,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack . push ( v2 ) ;
break ;
case OP_2ROT :
case Opcode . map . O P_2ROT :
// (x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2)
var v1 = this . stackTop ( 6 ) ;
var v2 = this . stackTop ( 5 ) ;
@ -232,13 +227,13 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack . push ( v2 ) ;
break ;
case OP_2SWAP :
case Opcode . map . O P_2SWAP :
// (x1 x2 x3 x4 -- x3 x4 x1 x2)
this . stackSwap ( 4 , 2 ) ;
this . stackSwap ( 3 , 1 ) ;
break ;
case OP_IFDUP :
case Opcode . map . O P_IFDUP :
// (x - 0 | x x)
var value = this . stackTop ( ) ;
if ( castBool ( value ) ) {
@ -246,23 +241,23 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
}
break ;
case OP_DEPTH :
case Opcode . map . O P_DEPTH :
// -- stacksize
var value = bignum ( this . stack . length ) ;
this . stack . push ( intToBufferSM ( value ) ) ;
break ;
case OP_DROP :
case Opcode . map . O P_DROP :
// (x -- )
this . stackPop ( ) ;
break ;
case OP_DUP :
case Opcode . map . O P_DUP :
// (x -- x x)
this . stack . push ( this . stackTop ( ) ) ;
break ;
case OP_NIP :
case Opcode . map . O P_NIP :
// (x1 x2 -- x2)
if ( this . stack . length < 2 ) {
throw new Error ( "OP_NIP insufficient stack size" ) ;
@ -270,13 +265,13 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack . splice ( this . stack . length - 2 , 1 ) ;
break ;
case OP_OVER :
case Opcode . map . O P_OVER :
// (x1 x2 -- x1 x2 x1)
this . stack . push ( this . stackTop ( 2 ) ) ;
break ;
case OP_PICK :
case OP_ROLL :
case Opcode . map . O P_PICK :
case Opcode . map . O P_ROLL :
// (xn ... x2 x1 x0 n - xn ... x2 x1 x0 xn)
// (xn ... x2 x1 x0 n - ... x2 x1 x0 xn)
var n = castInt ( this . stackPop ( ) ) ;
@ -284,13 +279,13 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
throw new Error ( "OP_PICK/OP_ROLL insufficient stack size" ) ;
}
var value = this . stackTop ( n + 1 ) ;
if ( opcode === OP_ROLL ) {
if ( opcode === Opcode . map . O P_ROLL ) {
this . stack . splice ( this . stack . length - n - 1 , 1 ) ;
}
this . stack . push ( value ) ;
break ;
case OP_ROT :
case Opcode . map . O P_ROT :
// (x1 x2 x3 -- x2 x3 x1)
// x2 x1 x3 after first swap
// x2 x3 x1 after second swap
@ -298,12 +293,12 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stackSwap ( 2 , 1 ) ;
break ;
case OP_SWAP :
case Opcode . map . O P_SWAP :
// (x1 x2 -- x2 x1)
this . stackSwap ( 2 , 1 ) ;
break ;
case OP_TUCK :
case Opcode . map . O P_TUCK :
// (x1 x2 -- x2 x1 x2)
if ( this . stack . length < 2 ) {
throw new Error ( "OP_TUCK insufficient stack size" ) ;
@ -311,7 +306,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack . splice ( this . stack . length - 2 , 0 , this . stackTop ( ) ) ;
break ;
case OP_CAT :
case Opcode . map . O P_CAT :
// (x1 x2 -- out)
var v1 = this . stackTop ( 2 ) ;
var v2 = this . stackTop ( 1 ) ;
@ -320,7 +315,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack . push ( Buffer . concat ( [ v1 , v2 ] ) ) ;
break ;
case OP_SUBSTR :
case Opcode . map . O P_SUBSTR :
// (in begin size -- out)
var buf = this . stackTop ( 3 ) ;
var start = castInt ( this . stackTop ( 2 ) ) ;
@ -336,8 +331,8 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack [ this . stack . length - 1 ] = buf . slice ( start , start + len ) ;
break ;
case OP_LEFT :
case OP_RIGHT :
case Opcode . map . O P_LEFT :
case Opcode . map . O P_RIGHT :
// (in size -- out)
var buf = this . stackTop ( 2 ) ;
var size = castInt ( this . stackTop ( 1 ) ) ;
@ -348,20 +343,20 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
size = buf . length ;
}
this . stackPop ( ) ;
if ( opcode === OP_LEFT ) {
if ( opcode === Opcode . map . O P_LEFT ) {
this . stack [ this . stack . length - 1 ] = buf . slice ( 0 , size ) ;
} else {
this . stack [ this . stack . length - 1 ] = buf . slice ( buf . length - size ) ;
}
break ;
case OP_SIZE :
case Opcode . map . O P_SIZE :
// (in -- in size)
var value = bignum ( this . stackTop ( ) . length ) ;
this . stack . push ( intToBufferSM ( value ) ) ;
break ;
case OP_INVERT :
case Opcode . map . O P_INVERT :
// (in - out)
var buf = this . stackTop ( ) ;
for ( var i = 0 , l = buf . length ; i < l ; i ++ ) {
@ -369,24 +364,24 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
}
break ;
case OP_AND :
case OP_OR :
case OP_XOR :
case Opcode . map . O P_AND :
case Opcode . map . O P_OR :
case Opcode . map . O P_XOR :
// (x1 x2 - out)
var v1 = this . stackTop ( 2 ) ;
var v2 = this . stackTop ( 1 ) ;
this . stackPop ( ) ;
this . stackPop ( ) ;
var out = new Buffer ( Math . max ( v1 . length , v2 . length ) ) ;
if ( opcode === OP_AND ) {
if ( opcode === Opcode . map . O P_AND ) {
for ( var i = 0 , l = out . length ; i < l ; i ++ ) {
out [ i ] = v1 [ i ] & v2 [ i ] ;
}
} else if ( opcode === OP_OR ) {
} else if ( opcode === Opcode . map . O P_OR ) {
for ( var i = 0 , l = out . length ; i < l ; i ++ ) {
out [ i ] = v1 [ i ] | v2 [ i ] ;
}
} else if ( opcode === OP_XOR ) {
} else if ( opcode === Opcode . map . O P_XOR ) {
for ( var i = 0 , l = out . length ; i < l ; i ++ ) {
out [ i ] = v1 [ i ] ^ v2 [ i ] ;
}
@ -394,8 +389,8 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack . push ( out ) ;
break ;
case OP_EQUAL :
case OP_EQUALVERIFY :
case Opcode . map . O P_EQUAL :
case Opcode . map . O P_EQUALVERIFY :
//case OP_NOTEQUAL: // use OP_NUMNOTEQUAL
// (x1 x2 - bool)
var v1 = this . stackTop ( 2 ) ;
@ -412,7 +407,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stackPop ( ) ;
this . stackPop ( ) ;
this . stack . push ( new Buffer ( [ value ? 1 : 0 ] ) ) ;
if ( opcode === OP_EQUALVERIFY ) {
if ( opcode === Opcode . map . O P_EQUALVERIFY ) {
if ( value ) {
this . stackPop ( ) ;
} else {
@ -421,136 +416,136 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
}
break ;
case OP_1ADD :
case OP_1SUB :
case OP_2MUL :
case OP_2DIV :
case OP_NEGATE :
case OP_ABS :
case OP_NOT :
case OP_0NOTEQUAL :
case Opcode . map . O P_1ADD :
case Opcode . map . O P_1SUB :
case Opcode . map . O P_2MUL :
case Opcode . map . O P_2DIV :
case Opcode . map . O P_NEGATE :
case Opcode . map . O P_ABS :
case Opcode . map . O P_NOT :
case Opcode . map . O P_0NOTEQUAL :
// (in -- out)
var num = bufferSMToInt ( this . stackTop ( ) ) ;
switch ( opcode ) {
case OP_1ADD :
case Opcode . map . O P_1ADD :
num = num . add ( bignum ( 1 ) ) ;
break ;
case OP_1SUB :
case Opcode . map . O P_1SUB :
num = num . sub ( bignum ( 1 ) ) ;
break ;
case OP_2MUL :
case Opcode . map . O P_2MUL :
num = num . mul ( bignum ( 2 ) ) ;
break ;
case OP_2DIV :
case Opcode . map . O P_2DIV :
num = num . div ( bignum ( 2 ) ) ;
break ;
case OP_NEGATE :
case Opcode . map . O P_NEGATE :
num = num . neg ( ) ;
break ;
case OP_ABS :
case Opcode . map . O P_ABS :
num = num . abs ( ) ;
break ;
case OP_NOT :
case Opcode . map . O P_NOT :
num = bignum ( num . cmp ( 0 ) == 0 ? 1 : 0 ) ;
break ;
case OP_0NOTEQUAL :
case Opcode . map . O P_0NOTEQUAL :
num = bignum ( num . cmp ( 0 ) == 0 ? 0 : 1 ) ;
break ;
}
this . stack [ this . stack . length - 1 ] = intToBufferSM ( num ) ;
break ;
case OP_ADD :
case OP_SUB :
case OP_MUL :
case OP_DIV :
case OP_MOD :
case OP_LSHIFT :
case OP_RSHIFT :
case OP_BOOLAND :
case OP_BOOLOR :
case OP_NUMEQUAL :
case OP_NUMEQUALVERIFY :
case OP_NUMNOTEQUAL :
case OP_LESSTHAN :
case OP_GREATERTHAN :
case OP_LESSTHANOREQUAL :
case OP_GREATERTHANOREQUAL :
case OP_MIN :
case OP_MAX :
case Opcode . map . O P_ADD :
case Opcode . map . O P_SUB :
case Opcode . map . O P_MUL :
case Opcode . map . O P_DIV :
case Opcode . map . O P_MOD :
case Opcode . map . O P_LSHIFT :
case Opcode . map . O P_RSHIFT :
case Opcode . map . O P_BOOLAND :
case Opcode . map . O P_BOOLOR :
case Opcode . map . O P_NUMEQUAL :
case Opcode . map . O P_NUMEQUALVERIFY :
case Opcode . map . O P_NUMNOTEQUAL :
case Opcode . map . O P_LESSTHAN :
case Opcode . map . O P_GREATERTHAN :
case Opcode . map . O P_LESSTHANOREQUAL :
case Opcode . map . O P_GREATERTHANOREQUAL :
case Opcode . map . O P_MIN :
case Opcode . map . O P_MAX :
// (x1 x2 -- out)
var v1 = bufferSMToInt ( this . stackTop ( 2 ) ) ;
var v2 = bufferSMToInt ( this . stackTop ( 1 ) ) ;
var num ;
switch ( opcode ) {
case OP_ADD :
case Opcode . map . O P_ADD :
num = v1 . add ( v2 ) ;
break ;
case OP_SUB :
case Opcode . map . O P_SUB :
num = v1 . sub ( v2 ) ;
break ;
case OP_MUL :
case Opcode . map . O P_MUL :
num = v1 . mul ( v2 ) ;
break ;
case OP_DIV :
case Opcode . map . O P_DIV :
num = v1 . div ( v2 ) ;
break ;
case OP_MOD :
case Opcode . map . O P_MOD :
num = v1 . mod ( v2 ) ;
break ;
case OP_LSHIFT :
case Opcode . map . O P_LSHIFT :
if ( v2 . cmp ( 0 ) < 0 || v2 . cmp ( 2048 ) > 0 ) {
throw new Error ( "OP_LSHIFT parameter out of bounds" ) ;
}
num = v1 . shiftLeft ( v2 ) ;
break ;
case OP_RSHIFT :
case Opcode . map . O P_RSHIFT :
if ( v2 . cmp ( 0 ) < 0 || v2 . cmp ( 2048 ) > 0 ) {
throw new Error ( "OP_RSHIFT parameter out of bounds" ) ;
}
num = v1 . shiftRight ( v2 ) ;
break ;
case OP_BOOLAND :
case Opcode . map . O P_BOOLAND :
num = bignum ( ( v1 . cmp ( 0 ) != 0 && v2 . cmp ( 0 ) != 0 ) ? 1 : 0 ) ;
break ;
case OP_BOOLOR :
case Opcode . map . O P_BOOLOR :
num = bignum ( ( v1 . cmp ( 0 ) != 0 || v2 . cmp ( 0 ) != 0 ) ? 1 : 0 ) ;
break ;
case OP_NUMEQUAL :
case OP_NUMEQUALVERIFY :
case Opcode . map . O P_NUMEQUAL :
case Opcode . map . O P_NUMEQUALVERIFY :
num = bignum ( v1 . cmp ( v2 ) == 0 ? 1 : 0 ) ;
break ;
case OP_NUMNOTEQUAL :
case Opcode . map . O P_NUMNOTEQUAL :
;
num = bignum ( v1 . cmp ( v2 ) != 0 ? 1 : 0 ) ;
break ;
case OP_LESSTHAN :
case Opcode . map . O P_LESSTHAN :
num = bignum ( v1 . lt ( v2 ) ? 1 : 0 ) ;
break ;
case OP_GREATERTHAN :
case Opcode . map . O P_GREATERTHAN :
num = bignum ( v1 . gt ( v2 ) ? 1 : 0 ) ;
break ;
case OP_LESSTHANOREQUAL :
case Opcode . map . O P_LESSTHANOREQUAL :
num = bignum ( v1 . gt ( v2 ) ? 0 : 1 ) ;
break ;
case OP_GREATERTHANOREQUAL :
case Opcode . map . O P_GREATERTHANOREQUAL :
num = bignum ( v1 . lt ( v2 ) ? 0 : 1 ) ;
break ;
case OP_MIN :
case Opcode . map . O P_MIN :
num = ( v1 . lt ( v2 ) ? v1 : v2 ) ;
break ;
case OP_MAX :
case Opcode . map . O P_MAX :
num = ( v1 . gt ( v2 ) ? v1 : v2 ) ;
break ;
}
@ -558,7 +553,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stackPop ( ) ;
this . stack . push ( intToBufferSM ( num ) ) ;
if ( opcode === OP_NUMEQUALVERIFY ) {
if ( opcode === Opcode . map . O P_NUMEQUALVERIFY ) {
if ( castBool ( this . stackTop ( ) ) ) {
this . stackPop ( ) ;
} else {
@ -567,7 +562,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
}
break ;
case OP_WITHIN :
case Opcode . map . O P_WITHIN :
// (x min max -- out)
var v1 = bufferSMToInt ( this . stackTop ( 3 ) ) ;
var v2 = bufferSMToInt ( this . stackTop ( 2 ) ) ;
@ -579,35 +574,35 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stack . push ( intToBufferSM ( value ? 1 : 0 ) ) ;
break ;
case OP_RIPEMD160 :
case OP_SHA1 :
case OP_SHA256 :
case OP_HASH160 :
case OP_HASH256 :
case Opcode . map . O P_RIPEMD160 :
case Opcode . map . O P_SHA1 :
case Opcode . map . O P_SHA256 :
case Opcode . map . O P_HASH160 :
case Opcode . map . O P_HASH256 :
// (in -- hash)
var value = this . stackPop ( ) ;
var hash ;
if ( opcode === OP_RIPEMD160 ) {
if ( opcode === Opcode . map . O P_RIPEMD160 ) {
hash = Util . ripe160 ( value ) ;
} else if ( opcode === OP_SHA1 ) {
} else if ( opcode === Opcode . map . O P_SHA1 ) {
hash = Util . sha1 ( value ) ;
} else if ( opcode === OP_SHA256 ) {
} else if ( opcode === Opcode . map . O P_SHA256 ) {
hash = Util . sha256 ( value ) ;
} else if ( opcode === OP_HASH160 ) {
} else if ( opcode === Opcode . map . O P_HASH160 ) {
hash = Util . sha256ripe160 ( value ) ;
} else if ( opcode === OP_HASH256 ) {
} else if ( opcode === Opcode . map . O P_HASH256 ) {
hash = Util . twoSha256 ( value ) ;
}
this . stack . push ( hash ) ;
break ;
case OP_CODESEPARATOR :
case Opcode . map . O P_CODESEPARATOR :
// Hash starts after the code separator
hashStart = pc ;
break ;
case OP_CHECKSIG :
case OP_CHECKSIGVERIFY :
case Opcode . map . O P_CHECKSIG :
case Opcode . map . O P_CHECKSIGVERIFY :
// (sig pubkey -- bool)
var sig = this . stackTop ( 2 ) ;
var pubkey = this . stackTop ( 1 ) ;
@ -640,7 +635,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
this . stackPop ( ) ;
this . stackPop ( ) ;
this . stack . push ( new Buffer ( [ success ? 1 : 0 ] ) ) ;
if ( opcode === OP_CHECKSIGVERIFY ) {
if ( opcode === Opcode . map . O P_CHECKSIGVERIFY ) {
if ( success ) {
this . stackPop ( ) ;
} else {
@ -656,8 +651,8 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
// the next opcode from being executed.
return ;
case OP_CHECKMULTISIG :
case OP_CHECKMULTISIGVERIFY :
case Opcode . map . O P_CHECKMULTISIG :
case Opcode . map . O P_CHECKMULTISIGVERIFY :
// ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool)
var keysCount = castInt ( this . stackPop ( ) ) ;
if ( keysCount < 0 || keysCount > 20 ) {
@ -729,7 +724,7 @@ ScriptInterpreter.prototype.eval = function eval(script, tx, inIndex, hashType,
} . bind ( this ) ) ;
} else {
this . stack . push ( new Buffer ( [ success ? 1 : 0 ] ) ) ;
if ( opcode === OP_CHECKMULTISIGVERIFY ) {
if ( opcode === Opcode . map . O P_CHECKMULTISIGVERIFY ) {
if ( success ) {
this . stackPop ( ) ;
} else {