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 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
|
// Mempool snapshot
|
||||||
|
|||||||
@ -575,11 +575,12 @@ Block.prototype.toJSON = function toJSON() {
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Block.prototype.getJSON = function getJSON(network, view, height) {
|
Block.prototype.getJSON = function getJSON(network, view, height, confirmations) {
|
||||||
network = Network.get(network);
|
network = Network.get(network);
|
||||||
return {
|
return {
|
||||||
hash: this.rhash(),
|
hash: this.rhash(),
|
||||||
height: height,
|
height: height,
|
||||||
|
confirmations: confirmations,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
prevBlock: util.revHex(this.prevBlock),
|
prevBlock: util.revHex(this.prevBlock),
|
||||||
merkleRoot: util.revHex(this.merkleRoot),
|
merkleRoot: util.revHex(this.merkleRoot),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user