Skip to content

Commit e47af29

Browse files
authored
Fix "chainlock" in WalletTxToJSON (#2748)
* Fix "chainlock" in WalletTxToJSON * Add `AssertLockHeld(cs_main); // for mapBlockIndex` * move assert higher
1 parent e21d8d6 commit e47af29

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/wallet/rpcwallet.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ void EnsureWalletIsUnlocked(CWallet * const pwallet)
6262

6363
void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
6464
{
65+
AssertLockHeld(cs_main); // for mapBlockIndex
6566
int confirms = wtx.GetDepthInMainChain();
6667
bool fLocked = instantsend.IsLockedInstantSendTransaction(wtx.GetHash());
67-
bool chainlock = llmq::chainLocksHandler->HasChainLock(wtx.nIndex, wtx.hashBlock);
68+
bool chainlock = false;
69+
if (confirms > 0) {
70+
chainlock = llmq::chainLocksHandler->HasChainLock(mapBlockIndex[wtx.hashBlock]->nHeight, wtx.hashBlock);
71+
}
6872
entry.push_back(Pair("confirmations", confirms));
6973
entry.push_back(Pair("instantlock", fLocked));
7074
entry.push_back(Pair("chainlock", chainlock));

0 commit comments

Comments
 (0)