Skip to content

Commit

Permalink
fix for tx confirmations when cache enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
pointbiz committed May 19, 2022
1 parent 7b2e1c5 commit ac8e131
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions routes/baseRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@ router.get("/tx/:transactionId", asyncHandler(async (req, res, next) => {
} else {
promises.push(utils.timePromise("tx.getblockheader", async () => {
res.locals.result.getblock = await global.rpcClient.command('getblockheader', tx.blockhash);
var blockHeader = res.locals.result.getblock;
// fix confirmations for cached transactions
if (!config.noInmemoryRpcCache && blockHeader && blockHeader.height) {
rpcApi.getBlockCount().then(function(blockcount){
var confs = blockcount - blockHeader.height + 1;
res.locals.tx.confirmations = confs;
res.locals.result.getrawtransaction.confirmations = confs;
});
}
}, perfResults));
}

Expand Down

0 comments on commit ac8e131

Please sign in to comment.