diff --git a/lib/script_interpreter.js b/lib/script_interpreter.js index 88b1f0d..cbcc7e0 100644 --- a/lib/script_interpreter.js +++ b/lib/script_interpreter.js @@ -162,6 +162,7 @@ ScriptInterpreter.prototype.checkPubkeyEncoding = function(buf) { * bitcoind commit: b5d1b1092998bc95313856d535c632ea5a8f9104 */ ScriptInterpreter.prototype.evaluate = function() { + console.log(this.script.toString()); if (this.script.toBuffer().length > 10000) { this.errstr = 'SCRIPT_ERR_SCRIPT_SIZE'; return false; @@ -883,7 +884,6 @@ ScriptInterpreter.prototype.step = function() { subscript.findAndDelete(tmpScript); if (!this.checkSignatureEncoding(bufSig) || !this.checkPubkeyEncoding(bufPubkey)) { - // serror is set return false; } @@ -973,7 +973,6 @@ ScriptInterpreter.prototype.step = function() { var bufPubkey = this.stack[this.stack.length - ikey]; if (!this.checkSignatureEncoding(bufSig) || !this.checkPubkeyEncoding(bufPubkey)) { - // serror is set return false; } @@ -1141,7 +1140,6 @@ ScriptInterpreter.prototype.verify = function(scriptSig, scriptPubkey, tx, nin, // evaluate redeemScript if (!this.evaluate()) - // serror is set return false; if (stackCopy.length === 0) { diff --git a/lib/transaction/sighash.js b/lib/transaction/sighash.js index 0d2782f..30ebf6f 100644 --- a/lib/transaction/sighash.js +++ b/lib/transaction/sighash.js @@ -11,6 +11,7 @@ var BN = require('../crypto/bn'); var Hash = require('../crypto/hash'); var ECDSA = require('../crypto/ecdsa'); var $ = require('../util/preconditions'); +var _ = require('lodash'); var SIGHASH_SINGLE_BUG = '0000000000000000000000000000000000000000000000000000000000000001'; var BITS_64_ON = 'ffffffffffffffff'; @@ -122,8 +123,8 @@ function sign(transaction, privateKey, sighashType, inputIndex, subscript) { * @return {boolean} */ function verify(transaction, signature, publicKey, inputIndex, subscript) { - $.checkArgument(transaction); - $.checkArgument(signature && signature.nhashtype); + $.checkArgument(!_.isUndefined(transaction)); + $.checkArgument(!_.isUndefined(signature) && !_.isUndefined(signature.nhashtype)); var hashbuf = sighash(transaction, signature.nhashtype, inputIndex, subscript); return ECDSA.verify(hashbuf, signature, publicKey, 'little'); } diff --git a/test/script_interpreter.js b/test/script_interpreter.js index 085602a..aa84687 100644 --- a/test/script_interpreter.js +++ b/test/script_interpreter.js @@ -247,7 +247,6 @@ describe('ScriptInterpreter', function() { var tx = Transaction(txhex); tx.inputs.forEach(function(txin, j) { - console.log('input ' + j); var scriptSig = txin.script; var txidhex = txin.prevTxId.toString('hex'); var txoutnum = txin.outputIndex;