From 39ba45f3c703488f4cb02f6bd907531bbaf660d9 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 27 Mar 2019 10:34:22 +0300 Subject: [PATCH] Show chainlocked txes as fully confirmed (#2807) --- src/qt/transactiondesc.cpp | 7 ++++++- src/qt/transactionrecord.cpp | 2 +- src/wallet/wallet.cpp | 11 +++++++++++ src/wallet/wallet.h | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 7f3385dfd8250..d2578bc094a6b 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -43,15 +43,20 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx) QString strTxStatus; bool fOffline = (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60) && (wtx.GetRequestCount() == 0); + bool fChainLocked = wtx.IsChainLocked(); if (fOffline) { strTxStatus = tr("%1/offline").arg(nDepth); } else if (nDepth == 0) { strTxStatus = tr("0/unconfirmed, %1").arg((wtx.InMempool() ? tr("in memory pool") : tr("not in memory pool"))) + (wtx.isAbandoned() ? ", "+tr("abandoned") : ""); - } else if (nDepth < 6) { + } else if (!fChainLocked && nDepth < 6) { strTxStatus = tr("%1/unconfirmed").arg(nDepth); } else { strTxStatus = tr("%1 confirmations").arg(nDepth); + if (fChainLocked) { + strTxStatus += " (" + tr("locked via LLMQ based ChainLocks") + ")"; + return strTxStatus; + } } if (llmq::quorumInstantSendManager->IsLocked(wtx.GetHash())) { diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 0365094774d9f..8dc69fc79fe95 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -329,7 +329,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) if (wtx.isAbandoned()) status.status = TransactionStatus::Abandoned; } - else if (status.depth < RecommendedNumConfirmations) + else if (!wtx.IsChainLocked() && status.depth < RecommendedNumConfirmations) { status.status = TransactionStatus::Confirming; } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 057a86add841d..34e4b4e8b58b9 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -37,6 +37,7 @@ #include "evo/providertx.h" #include "llmq/quorums_instantsend.h" +#include "llmq/quorums_chainlocks.h" #include @@ -5404,6 +5405,16 @@ bool CMerkleTx::IsLockedByInstantSend() const return instantsend.IsLockedInstantSendTransaction(GetHash()) || llmq::quorumInstantSendManager->IsLocked(GetHash()); } +bool CMerkleTx::IsChainLocked() const +{ + AssertLockHeld(cs_main); + BlockMap::iterator mi = mapBlockIndex.find(hashBlock); + if (mi != mapBlockIndex.end() && mi->second != nullptr) { + return llmq::chainLocksHandler->HasChainLock(mi->second->nHeight, hashBlock); + } + return false; +} + int CMerkleTx::GetBlocksToMaturity() const { if (!IsCoinBase()) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 4c9ce788b113b..8f6d4a5122b19 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -271,6 +271,7 @@ class CMerkleTx int GetDepthInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); } bool IsInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet) > 0; } bool IsLockedByInstantSend() const; + bool IsChainLocked() const; int GetBlocksToMaturity() const; /** Pass this transaction to the mempool. Fails if absolute fee exceeds absurd fee. */ bool AcceptToMemoryPool(const CAmount& nAbsurdFee, CValidationState& state);