From ac8e1312d7cc34636adea907a2c2646c2a909d2d Mon Sep 17 00:00:00 2001 From: pointbiz Date: Thu, 22 Apr 2021 17:24:22 -0400 Subject: [PATCH] fix for tx confirmations when cache enabled --- routes/baseRouter.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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)); }