fix pool.isWatched.

This commit is contained in:
Christopher Jeffrey 2016-01-04 10:37:58 -08:00
parent eef4103296
commit 50e606f625

View File

@ -745,7 +745,7 @@ Pool.prototype.unwatch = function unwatch(id) {
// See "Filter matching algorithm":
// https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki
Pool.prototype.isWatched = function(tx, bloom) {
var i, input, output, outHash;
var i, input, output, prev;
if (!bloom)
bloom = this.bloom;
@ -775,19 +775,19 @@ Pool.prototype.isWatched = function(tx, bloom) {
// 4. Test data elements in input scripts
for (i = 0; i < tx.inputs.length; i++) {
input = tx.inputs[i];
outHash = input.out.hash;
prev = input.out.hash;
if (typeof outHash === 'string')
outHash = utils.toArray(outHash, 'hex');
if (typeof prev === 'string')
prev = utils.toArray(prev, 'hex');
// Test the prev_out tx hash
if (bloom.test(outHash))
if (bloom.test(prev))
return true;
// Test the prev_out script
if (input.out.tx) {
output = input.out.tx.outputs[input.out.index];
if (testScript(output.script))
prev = input.out.tx.outputs[input.out.index];
if (testScript(prev.script))
return true;
}