From 0987b3d0a7298d35592323c4163744d476451848 Mon Sep 17 00:00:00 2001 From: Zannick Date: Fri, 22 Oct 2021 13:39:05 -0700 Subject: [PATCH] Lock cs_main before calling GetBlocksToMaturity This is similar to another call, just somehow missed this one earlier. --- src/wallet/rpcwallet.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ea28d07706..82f3755089 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2527,10 +2527,18 @@ static void ExportTransactions(CWallet* const pwallet, const CWalletTx& wtx, con { if (wtx.GetDepthInMainChain() < 1) csvRecord[TRANSACTION_CSV_FIELD_CATEGORY] = "orphan"; - else if (wtx.GetBlocksToMaturity() > 0) - csvRecord[TRANSACTION_CSV_FIELD_CATEGORY] = "immature"; else - csvRecord[TRANSACTION_CSV_FIELD_CATEGORY] = "generate"; + { + int nBlocksToMaturity; + { + LOCK(cs_main); + nBlocksToMaturity = wtx.GetBlocksToMaturity(); + } + if (nBlocksToMaturity > 0) + csvRecord[TRANSACTION_CSV_FIELD_CATEGORY] = "immature"; + else + csvRecord[TRANSACTION_CSV_FIELD_CATEGORY] = "generate"; + } } else {