From 37db8daa1912bced2da48763caa7aba830ef31fa Mon Sep 17 00:00:00 2001 From: Dan Janosik Date: Sat, 14 Jul 2018 19:13:38 -0400 Subject: [PATCH] fix for block-total-fees calculation bug when coinbase tx value is split across multiple addresses, ala block #531942 --- app/utils.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/utils.js b/app/utils.js index 5108cb1..2533a89 100644 --- a/app/utils.js +++ b/app/utils.js @@ -203,19 +203,15 @@ function getBlockTotalFeesFromCoinbaseTxAndBlockHeight(coinbaseTx, blockHeight) var blockReward = coinConfig.blockRewardFunction(blockHeight); - var totalOutput = -1; + var totalOutput = new Decimal(0); for (var i = 0; i < coinbaseTx.vout.length; i++) { var outputValue = coinbaseTx.vout[i].value; - if (outputValue >= blockReward) { - totalOutput = outputValue; + if (outputValue > 0) { + totalOutput = totalOutput.plus(new Decimal(outputValue)); } } - if (totalOutput == -1) { - return 0; - } - - return new Decimal(totalOutput).minus(new Decimal(blockReward)); + return totalOutput.minus(new Decimal(blockReward)); } function refreshExchangeRate() {