fix tx-pool unspent output handling. fixes #26.
This commit is contained in:
parent
3a7b20ddee
commit
2e14fe1780
@ -70,7 +70,8 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
|||||||
}
|
}
|
||||||
this._all[hash] = tx;
|
this._all[hash] = tx;
|
||||||
|
|
||||||
var own = this._wallet.ownOutput(tx);
|
var ownInput = this._wallet.ownInput(tx);
|
||||||
|
var ownOutput = this._wallet.ownOutput(tx);
|
||||||
var updated = false;
|
var updated = false;
|
||||||
|
|
||||||
// Consume unspent money or add orphans
|
// Consume unspent money or add orphans
|
||||||
@ -92,7 +93,16 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!own)
|
// Only add orphans if the tx has outputs that are ours.
|
||||||
|
// if (!ownOutput)
|
||||||
|
// continue;
|
||||||
|
|
||||||
|
// Only add orphans if this input is ours or the tx has outputs that are ours.
|
||||||
|
// if (!ownOutput && (!ownInput || !~ownInput.indexOf(input)))
|
||||||
|
// continue;
|
||||||
|
|
||||||
|
// Only add orphans if this input is ours.
|
||||||
|
if (!ownInput || !~ownInput.indexOf(input))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Add orphan, if no parent transaction is yet known
|
// Add orphan, if no parent transaction is yet known
|
||||||
@ -103,7 +113,7 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
|||||||
this._orphans[key] = [orphan];
|
this._orphans[key] = [orphan];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!own) {
|
if (!ownOutput) {
|
||||||
if (updated)
|
if (updated)
|
||||||
this.emit('update', this._lastTs, tx);
|
this.emit('update', this._lastTs, tx);
|
||||||
|
|
||||||
@ -130,6 +140,11 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
|||||||
for (var i = 0; i < tx.outputs.length; i++) {
|
for (var i = 0; i < tx.outputs.length; i++) {
|
||||||
var out = tx.outputs[i];
|
var out = tx.outputs[i];
|
||||||
|
|
||||||
|
// Do not add unspents for outputs that aren't ours.
|
||||||
|
if (!~ownOutput.indexOf(out)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var key = hash + '/' + i;
|
var key = hash + '/' + i;
|
||||||
var orphans = this._orphans[key];
|
var orphans = this._orphans[key];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user