diff --git a/routes/baseRouter.js b/routes/baseRouter.js index f100d1ef7..fed00674a 100644 --- a/routes/baseRouter.js +++ b/routes/baseRouter.js @@ -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)); }