Adding 'confirmations' property to block getJSON
Adds a 'confirmations' property to the JSON returned by `cli tx [hash]` as well as the Rest `/tx/:hash` call by subtracting block height from chain height
This commit is contained in:
parent
0f68427778
commit
c2cef86296
@ -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
|
||||
|
||||
@ -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),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user