diff --git a/lib/blocks.js b/lib/blocks.js index 3ba0e9f17..a22e4c854 100644 --- a/lib/blocks.js +++ b/lib/blocks.js @@ -135,7 +135,7 @@ BlockController.prototype.transformBlock = function(block, info) { confirmations: info.confirmations, previousblockhash: this._normalizePrevHash(blockObj.header.prevHash), nextblockhash: info.nextHash, - reward: this.getBlockReward(info.height) / 1e8, + reward: this.getBlockReward(info.height, (info.confirmations !== -1)) / 1e8, isMainChain: (info.confirmations !== -1), poolInfo: this.getPoolInfo(block) }; @@ -330,7 +330,7 @@ BlockController.prototype.formatTimestamp = function(date) { return yyyy + '-' + (mm[1] ? mm : '0' + mm[0]) + '-' + (dd[1] ? dd : '0' + dd[0]); //padding }; -BlockController.prototype.getBlockReward = function(height) { +BlockController.prototype.getBlockReward = function(height, isMainChain) { var subsidy = new BN(12.5 * 1e8); // Mining slow start @@ -347,11 +347,24 @@ BlockController.prototype.getBlockReward = function(height) { } var halvings = Math.floor((height - (20000/2)) / 840000); + + // Adjust for Blossom (see zcash src/chainparams.cpp) + if (isMainChain) { // mainnet + if (height >= 653600) { + halvings++; + } + } else { // testnet + if (height >= 584000) { + halvings++; + } + } + // Force block reward to zero when right shift is undefined. if (halvings >= 64) { return 0; } + // Subsidy is cut in half every 840,000 blocks which will occur approximately every 4 years. subsidy = subsidy.shrn(halvings);