Browse Source

fix for block-total-fees calculation bug when coinbase tx value is split across multiple addresses, ala block #531942

fix-133-memory-crash
Dan Janosik 7 years ago
parent
commit
37db8daa19
  1. 12
      app/utils.js

12
app/utils.js

@ -203,19 +203,15 @@ function getBlockTotalFeesFromCoinbaseTxAndBlockHeight(coinbaseTx, blockHeight)
var blockReward = coinConfig.blockRewardFunction(blockHeight); var blockReward = coinConfig.blockRewardFunction(blockHeight);
var totalOutput = -1; var totalOutput = new Decimal(0);
for (var i = 0; i < coinbaseTx.vout.length; i++) { for (var i = 0; i < coinbaseTx.vout.length; i++) {
var outputValue = coinbaseTx.vout[i].value; var outputValue = coinbaseTx.vout[i].value;
if (outputValue >= blockReward) { if (outputValue > 0) {
totalOutput = outputValue; totalOutput = totalOutput.plus(new Decimal(outputValue));
} }
} }
if (totalOutput == -1) { return totalOutput.minus(new Decimal(blockReward));
return 0;
}
return new Decimal(totalOutput).minus(new Decimal(blockReward));
} }
function refreshExchangeRate() { function refreshExchangeRate() {

Loading…
Cancel
Save