tx-pool fixes.

This commit is contained in:
Christopher Jeffrey 2016-02-15 15:37:33 -08:00
parent 39ecd292b3
commit 7a32e510e9

View File

@ -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;