From 8a8b664061a123d93fc60451e41d57f9fe9d8519 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 28 Feb 2016 06:05:59 -0800 Subject: [PATCH] more fixes. cleanup debugging. --- lib/bcoin/chain.js | 9 --------- lib/bcoin/protocol/constants.js | 2 +- lib/bcoin/script.js | 5 ----- lib/bcoin/tx.js | 12 +++++++----- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/bcoin/chain.js b/lib/bcoin/chain.js index 3988492f..b07fdb1a 100644 --- a/lib/bcoin/chain.js +++ b/lib/bcoin/chain.js @@ -660,12 +660,6 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, callbac var i, j, input, hash; var sigops = 0; - // utils.print(height); - // utils.print(block.commitmentHash ? utils.revHex(block.commitmentHash) : null); - // utils.print(utils.revHex(block.getCommitmentHash() || '00')); - // utils.print(block.txs[0]); - // utils.print(block.txs[1]); - if (err) return callback(err); @@ -711,9 +705,6 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, callbac throw new Error('BUG: Bad inputs in historical data!'); return callback(null, false); } - - if (input.output.getType() === 'scripthash') - utils.debug(tx); } if (!scriptCheck) diff --git a/lib/bcoin/protocol/constants.js b/lib/bcoin/protocol/constants.js index d4cc8a85..98a182d7 100644 --- a/lib/bcoin/protocol/constants.js +++ b/lib/bcoin/protocol/constants.js @@ -294,7 +294,7 @@ exports.flags = { VERIFY_CLEANSTACK: (1 << 8), VERIFY_CHECKLOCKTIMEVERIFY: (1 << 9), VERIFY_WITNESS: (1 << 10), - VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM: (1 << 9) + VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM: (1 << 11) }; // Block validation diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index 91edec77..ee148c59 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -462,13 +462,8 @@ script.verifyProgram = function verifyProgram(witness, output, tx, i, flags) { return false; } - utils.debug(bcoin.script.format(stack)); - utils.debug(bcoin.script.format(redeem)); - res = script.execute(redeem, stack, tx, i, flags, 1); - utils.debug(bcoin.script.format(stack)); - // Verify the script did not fail as well as the stack values if (!res || stack.length === 0 || !script.bool(stack.pop())) return false; diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index 2c6d8869..fd96f54f 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -131,12 +131,14 @@ TX.prototype.witnessHash = function witnessHash(enc) { }; TX.prototype.hasWitness = function hasWitness() { - if (this.inputs.length === 0) - return false; + var i; - return this.inputs.every(function(input) { - return input.witness.length > 0; - }); + for (i = 0; i < this.inputs.length; i++) { + if (this.inputs[i].witness.length > 0) + return true; + } + + return false; }; TX.prototype.render = function render() {