From 260cc09de23faea555f2bb613ebaff2b75e4d014 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 11 Feb 2021 19:36:09 +0300 Subject: [PATCH] qt: Fix labels in transaction list (#3993) * qt: Fix labels in transaction list The issue was introduced in #3682 * qt: Always use labels from TransactionStatus for transaction list Missed this in #3155 * Update src/qt/transactiontablemodel.cpp Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> --- src/qt/transactionrecord.cpp | 3 +-- src/qt/transactiontablemodel.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index e3aeca2b91a6e..b3e87dcf040e7 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -50,7 +50,6 @@ QList TransactionRecord::decomposeTransaction(const interface if(mine) { TransactionRecord sub(hash, nTime); - CTxDestination address; sub.idx = i; // vout index sub.credit = txout.nValue; sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY; @@ -59,7 +58,7 @@ QList TransactionRecord::decomposeTransaction(const interface // Received by Dash Address sub.type = TransactionRecord::RecvWithAddress; sub.strAddress = EncodeDestination(wtx.txout_address[i]); - sub.txDest = address; + sub.txDest = wtx.txout_address[i]; } else { diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 606a8929dfbd1..fbfc6597e93a0 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -4,7 +4,6 @@ #include -#include #include #include #include @@ -205,6 +204,15 @@ class TransactionTablePriv int64_t adjustedTime; if (rec->statusUpdateNeeded(numBlocks, parent->getChainLockHeight()) && wallet.tryGetTxStatus(rec->hash, wtx, adjustedTime)) { rec->updateStatus(wtx, numBlocks, adjustedTime, parent->getChainLockHeight()); + // Update label + if (IsValidDestination(rec->txDest)) { + std::string name; + if (wallet.getAddress(rec->txDest, &name)) { + rec->status.label = QString::fromStdString(name); + } else { + rec->status.label = ""; + } + } } return rec; } @@ -451,9 +459,9 @@ QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const case TransactionRecord::PrivateSend: case TransactionRecord::RecvWithPrivateSend: { - QString label = walletModel->getAddressTableModel()->labelForDestination(wtx->txDest); - if(label.isEmpty()) + if (wtx->status.label.isEmpty()) { return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BAREADDRESS); + } } break; case TransactionRecord::SendToSelf: case TransactionRecord::PrivateSendCreateDenominations: