From 7a32e510e9820cc42fde46b6563f6ef432201c67 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 15 Feb 2016 15:37:33 -0800 Subject: [PATCH] tx-pool fixes. --- lib/bcoin/tx-pool.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/bcoin/tx-pool.js b/lib/bcoin/tx-pool.js index ac6f754c..990142bc 100644 --- a/lib/bcoin/tx-pool.js +++ b/lib/bcoin/tx-pool.js @@ -140,8 +140,10 @@ TXPool.prototype.add = function add(tx, noWrite, strict) { } // Only add orphans if this input is ours. - if (!this._wallet.ownInput(input)) - continue; + if (input.output) { + if (!this._wallet.ownInput(input)) + continue; + } // Add orphan, if no parent transaction is yet known orphan = { tx: tx, index: i }; @@ -237,16 +239,19 @@ TXPool.prototype._storeTX = function _storeTX(hash, tx, noWrite) { TXPool.prototype._removeTX = function _removeTX(tx, noWrite) { var self = this; + var hash = tx.hash('hex'); var key; for (var i = 0; i < tx.outputs.length; i++) { - key = tx.hash('hex') + '/' + i; + key = hash + '/' + i; if (this._unspent[key]) { delete this._unspent[key]; this._removeOutput(tx, i); } } + // delete this._all[hash]; + if (!this._storage || noWrite) return; @@ -360,7 +365,7 @@ TXPool.prototype.getUnspent = function getUnspent(address) { return this._unspent[key]; }, this).filter(function(unspent) { if (address) { - if (!unspent.test(address) && !unspent.test(address)) + if (!unspent.test(address)) return false; } return true;