From 6ab493231ef4e8279023f15ca496e1ae7cf0ee50 Mon Sep 17 00:00:00 2001 From: lateminer <9951982+lateminer@users.noreply.github.com> Date: Wed, 20 Sep 2023 21:57:52 +0200 Subject: [PATCH] pos: Check if there is g_txindex before trying to access it --- src/wallet/wallet.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d9d627d212..f3d08e72e6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4018,6 +4018,10 @@ bool CWallet::CreateCoinStake(ChainstateManager& chainman, const CWallet* pwalle CScript scriptPubKeyKernel, scriptPubKeyOut; for (const std::pair &pcoin : setCoins) { + if (!g_txindex) { + return error("tx index not available!"); + } + uint256 blockHash; CTransactionRef tx; if (!g_txindex->FindTx(pcoin.first->GetHash(), blockHash, tx)) { @@ -4078,6 +4082,10 @@ bool CWallet::CreateCoinStake(ChainstateManager& chainman, const CWallet* pwalle for (const std::pair &pcoin : setCoins) { + if (!g_txindex) { + return error("tx index not available!"); + } + uint256 blockHash; CTransactionRef tx; if (!g_txindex->FindTx(pcoin.first->GetHash(), blockHash, tx)) {