Fix "chainlock" in WalletTxToJSON (#2748)

* Fix "chainlock" in WalletTxToJSON

* Add `AssertLockHeld(cs_main); // for mapBlockIndex`

* move assert higher
This commit is contained in:
UdjinM6 2019-03-07 16:29:37 +03:00 committed by GitHub
parent e21d8d6b95
commit e47af29d41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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));