diff --git a/lib/http/server.js b/lib/http/server.js index f2ff9332..23fb3d97 100644 --- a/lib/http/server.js +++ b/lib/http/server.js @@ -279,8 +279,9 @@ HTTPServer.prototype.initRouter = function initRouter() { } const height = await this.chain.getHeight(hash); + const confirmations = this.chain.height - height; - res.send(200, block.getJSON(this.network, view, height)); + res.send(200, block.getJSON(this.network, view, height, confirmations)); }); // Mempool snapshot diff --git a/lib/primitives/block.js b/lib/primitives/block.js index ae9c8918..9be79213 100644 --- a/lib/primitives/block.js +++ b/lib/primitives/block.js @@ -575,11 +575,12 @@ Block.prototype.toJSON = function toJSON() { * @returns {Object} */ -Block.prototype.getJSON = function getJSON(network, view, height) { +Block.prototype.getJSON = function getJSON(network, view, height, confirmations) { network = Network.get(network); return { hash: this.rhash(), height: height, + confirmations: confirmations, version: this.version, prevBlock: util.revHex(this.prevBlock), merkleRoot: util.revHex(this.merkleRoot),