Browse Source

Fix #106

When computing send/receive values for an address, don't improperly attribute all previous-tx sends as coming from the address of interest
fix-133-memory-crash
Dan Janosik 6 years ago
parent
commit
6e78c83d40
No known key found for this signature in database GPG Key ID: C6F8CE9FFDB2CED2
  1. 7
      routes/baseActionsRouter.js

7
routes/baseActionsRouter.js

@ -678,16 +678,15 @@ router.get("/address/:address", function(req, res) {
for (var j = 0; j < tx.vin.length; j++) {
var txInput = txInputs[j];
var vinJ = tx.vin[j];
if (txInput != null) {
for (var k = 0; k < txInput.vout.length; k++) {
if (txInput.vout[k] && txInput.vout[k].scriptPubKey && txInput.vout[k].scriptPubKey.addresses && txInput.vout[k].scriptPubKey.addresses.includes(address)) {
if (txInput.vout[vinJ.vout] && txInput.vout[vinJ.vout].scriptPubKey && txInput.vout[vinJ.vout].scriptPubKey.addresses && txInput.vout[vinJ.vout].scriptPubKey.addresses.includes(address)) {
if (addrLossesByTx[tx.txid] == null) {
addrLossesByTx[tx.txid] = new Decimal(0);
}
addrLossesByTx[tx.txid] = addrLossesByTx[tx.txid].plus(new Decimal(txInput.vout[k].value));
}
addrLossesByTx[tx.txid] = addrLossesByTx[tx.txid].plus(new Decimal(txInput.vout[vinJ.vout].value));
}
}
}

Loading…
Cancel
Save