From e47af29d41be273ec2971fcd1e4334e1c0011d08 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 7 Mar 2019 16:29:37 +0300 Subject: [PATCH] Fix "chainlock" in WalletTxToJSON (#2748) * Fix "chainlock" in WalletTxToJSON * Add `AssertLockHeld(cs_main); // for mapBlockIndex` * move assert higher --- src/wallet/rpcwallet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 63c714085b..530f7d7257 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -62,9 +62,13 @@ void EnsureWalletIsUnlocked(CWallet * const pwallet) void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) { + AssertLockHeld(cs_main); // for mapBlockIndex int confirms = wtx.GetDepthInMainChain(); bool fLocked = instantsend.IsLockedInstantSendTransaction(wtx.GetHash()); - bool chainlock = llmq::chainLocksHandler->HasChainLock(wtx.nIndex, wtx.hashBlock); + bool chainlock = false; + if (confirms > 0) { + chainlock = llmq::chainLocksHandler->HasChainLock(mapBlockIndex[wtx.hashBlock]->nHeight, wtx.hashBlock); + } entry.push_back(Pair("confirmations", confirms)); entry.push_back(Pair("instantlock", fLocked)); entry.push_back(Pair("chainlock", chainlock));