blocks: fix null prevhash issue
This commit is contained in:
parent
6ec263692b
commit
b686c5bea9
@ -84,6 +84,15 @@ BlockController.prototype.rawBlock = function(req, res, next, blockArg) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BlockController.prototype._normalizePrevHash = function(hash) {
|
||||||
|
// TODO fix bitcore to give back null instead of null hash
|
||||||
|
if (hash !== '0000000000000000000000000000000000000000000000000000000000000000') {
|
||||||
|
return hash;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
BlockController.prototype.transformBlock = function(block, info) {
|
BlockController.prototype.transformBlock = function(block, info) {
|
||||||
var blockObj = block.toObject();
|
var blockObj = block.toObject();
|
||||||
var transactionIds = blockObj.transactions.map(function(tx) {
|
var transactionIds = blockObj.transactions.map(function(tx) {
|
||||||
@ -101,7 +110,7 @@ BlockController.prototype.transformBlock = function(block, info) {
|
|||||||
bits: blockObj.header.bits.toString(16),
|
bits: blockObj.header.bits.toString(16),
|
||||||
difficulty: block.header.getDifficulty(),
|
difficulty: block.header.getDifficulty(),
|
||||||
chainwork: info.chainwork,
|
chainwork: info.chainwork,
|
||||||
previousblockhash: blockObj.header.prevHash,
|
previousblockhash: this._normalizePrevHash(blockObj.header.prevHash),
|
||||||
nextblockhash: info.nextblockhash,
|
nextblockhash: info.nextblockhash,
|
||||||
reward: this.getBlockReward(info.height) / 1e8,
|
reward: this.getBlockReward(info.height) / 1e8,
|
||||||
isMainChain: (info.confirmations !== -1),
|
isMainChain: (info.confirmations !== -1),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user