From 0c4df11cb65de92e7196a08d6c4d785a053b118f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 31 May 2016 22:16:15 -0700 Subject: [PATCH] consistency. chain test. --- lib/bcoin/merkleblock.js | 6 +++--- lib/bcoin/tx.js | 20 ++++++++++---------- test/chain-test.js | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/bcoin/merkleblock.js b/lib/bcoin/merkleblock.js index 1503d002..cd7d258d 100644 --- a/lib/bcoin/merkleblock.js +++ b/lib/bcoin/merkleblock.js @@ -361,11 +361,11 @@ MerkleBlock.fromRaw = function fromRaw(data, enc) { * it through a filter first. This will build the partial * merkle tree. * @param {Block} block - * @param {Bloom} bloom + * @param {Bloom} filter * @returns {MerkleBlock} */ -MerkleBlock.fromBlock = function fromBlock(block, bloom) { +MerkleBlock.fromBlock = function fromBlock(block, filter) { var matches = []; var txs = []; var leaves = []; @@ -375,7 +375,7 @@ MerkleBlock.fromBlock = function fromBlock(block, bloom) { for (i = 0; i < block.txs.length; i++) { tx = block.txs[i]; - if (tx.isWatched(bloom)) { + if (tx.isWatched(filter)) { matches.push(1); txs.push(tx); } else { diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index fdaace65..7f060d2f 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -1604,14 +1604,14 @@ TX.prototype.getPrevout = function getPrevout() { * value is. * @see "Filter matching algorithm": * @see https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki - * @param {Bloom} bloom + * @param {Bloom} filter * @returns {Boolean} True if the transaction matched. */ -TX.prototype.isWatched = function isWatched(bloom) { +TX.prototype.isWatched = function isWatched(filter) { var i, input, output, hash, index, outpoint; - if (!bloom) + if (!filter) return false; function testScript(code) { @@ -1623,7 +1623,7 @@ TX.prototype.isWatched = function isWatched(bloom) { break; if (!Buffer.isBuffer(chunk) || chunk.length === 0) continue; - if (bloom.test(chunk)) + if (filter.test(chunk)) return true; } @@ -1631,7 +1631,7 @@ TX.prototype.isWatched = function isWatched(bloom) { } // 1. Test the tx hash - if (bloom.test(this.hash())) + if (filter.test(this.hash())) return true; // 2. Test data elements in output scripts @@ -1640,13 +1640,13 @@ TX.prototype.isWatched = function isWatched(bloom) { output = this.outputs[i]; // Test the output script if (testScript(output.script.code)) { - if (bloom.update === constants.filterFlags.ALL) { + if (filter.update === constants.filterFlags.ALL) { outpoint = bcoin.protocol.framer.outpoint(this.hash(), i); - bloom.add(outpoint); - } else if (bloom.update === constants.filterFlags.PUBKEY_ONLY) { + filter.add(outpoint); + } else if (filter.update === constants.filterFlags.PUBKEY_ONLY) { if (output.script.isPubkey() || output.script.isMultisig()) { outpoint = bcoin.protocol.framer.outpoint(this.hash(), i); - bloom.add(outpoint); + filter.add(outpoint); } } return true; @@ -1662,7 +1662,7 @@ TX.prototype.isWatched = function isWatched(bloom) { outpoint = bcoin.protocol.framer.outpoint(hash, index); // Test the COutPoint structure - if (bloom.test(outpoint)) + if (filter.test(outpoint)) return true; // Test the input script diff --git a/test/chain-test.js b/test/chain-test.js index 84ada32a..e1ae7f5c 100644 --- a/test/chain-test.js +++ b/test/chain-test.js @@ -40,7 +40,7 @@ describe('Chain', function() { value: utils.satoshi('25.0') }); redeemer.addOutput({ - address: wallet.deriveAddress(false, 100).getAddress(), + address: wallet.account.deriveAddress(false, 100).getAddress(), value: utils.satoshi('5.0') }); redeemer.addInput(tx, 0);