Skip to content

Commit a2d98d5

Browse files
committed
Fix block fee calculation
1 parent 10408f6 commit a2d98d5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Content.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,12 @@ function createBlocksContent(){
114114
$content["blocks"][$block["height"]]["timeago"] = round((time() - $block["time"])/60);
115115
$content["blocks"][$block["height"]]["coinbasetx"] = $block["tx"][0];
116116
$coinbaseTx = $bitcoind->getrawtransaction($block["tx"][0], 1, $block["hash"]);
117-
if($coinbaseTx["vout"][0]["value"] != 0){
118-
$content["blocks"][$block["height"]]["fees"] = round($coinbaseTx["vout"][0]["value"] - (50 / pow(2, floor($block["height"] / 210000))), 4) ;
119-
}else{
120-
$content["blocks"][$block["height"]]["fees"] = round($coinbaseTx["vout"][1]["value"] - (50 / pow(2, floor($block["height"] / 210000))), 4) ;
121-
}
117+
$currentReward = 50 / pow(2, floor($block["height"] / 210000));
118+
$accuReward = 0;
119+
foreach($coinbaseTx["vout"] as $vout){
120+
$accuReward += $vout["value"];
121+
}
122+
$content["blocks"][$block["height"]]["fees"] = round($accuReward - $currentReward, 4);
122123
$content["totalFees"] += $content["blocks"][$block["height"]]["fees"];
123124
$content["blocks"][$block["height"]]["txcount"] = count($block["tx"]);
124125
$content["totalTx"] += $content["blocks"][$block["height"]]["txcount"];

0 commit comments

Comments
 (0)