Skip to content

Commit a3c3ddb

Browse files
committed
[Qt] add InMempool() info to transaction details
1 parent 4077ad2 commit a3c3ddb

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/qt/transactiondesc.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
3535
{
3636
int nDepth = wtx.GetDepthInMainChain();
3737
if (nDepth < 0)
38-
return tr("conflicted");
38+
return tr("conflicted with a transaction with %1 confirmations").arg(-nDepth);
3939
else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
4040
return tr("%1/offline").arg(nDepth);
41+
else if (nDepth == 0)
42+
return tr("0/unconfirmed, %1").arg((wtx.InMempool() ? tr("in memory pool") : tr("not in memory pool")));
4143
else if (nDepth < 6)
4244
return tr("%1/unconfirmed").arg(nDepth);
4345
else

src/wallet/wallet.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,15 @@ CAmount CWalletTx::GetChange() const
13591359
return nChangeCached;
13601360
}
13611361

1362+
bool CWalletTx::InMempool() const
1363+
{
1364+
LOCK(mempool.cs);
1365+
if (mempool.exists(GetHash())) {
1366+
return true;
1367+
}
1368+
return false;
1369+
}
1370+
13621371
bool CWalletTx::IsTrusted() const
13631372
{
13641373
// Quick answer in most cases
@@ -1373,12 +1382,8 @@ bool CWalletTx::IsTrusted() const
13731382
return false;
13741383

13751384
// Don't trust unconfirmed transactions from us unless they are in the mempool.
1376-
{
1377-
LOCK(mempool.cs);
1378-
if (!mempool.exists(GetHash())) {
1379-
return false;
1380-
}
1381-
}
1385+
if (!InMempool())
1386+
return false;
13821387

13831388
// Trusted if all inputs are from us and are in the mempool:
13841389
BOOST_FOREACH(const CTxIn& txin, vin)

src/wallet/wallet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ class CWalletTx : public CMerkleTx
384384
// True if only scriptSigs are different
385385
bool IsEquivalentTo(const CWalletTx& tx) const;
386386

387+
bool InMempool() const;
387388
bool IsTrusted() const;
388389

389390
bool WriteToDisk(CWalletDB *pwalletdb);

0 commit comments

Comments
 (0)