Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QT] Show more descriptive label for pay to yourself entries #9985

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,9 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent
*/
QString AddressTableModel::labelForAddress(const QString &address) const
{
{
if (address.isEmpty())
return QString();
{
LOCK(wallet->cs_wallet);
CBitcoinAddress address_parsed(address.toStdString());
std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(address_parsed.Get());
Expand Down
9 changes: 7 additions & 2 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
{
// Payment to self
CAmount nChange = wtx.GetChange();

parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
std::string address;
CTxDestination destAddress;
if (wtx.tx->vout.size() >= 1 && ExtractDestination(wtx.tx->vout[0].scriptPubKey, destAddress))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list only the first to-yourself-output. But I think this is okay.

{
address = CBitcoinAddress(destAddress).ToString();
}
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, address,
-(nDebit - nChange), nCredit - nChange));
parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to TransactionRecord as constructor argument
}
Expand Down
8 changes: 4 additions & 4 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ QString TransactionTableModel::lookupAddress(const std::string &address, bool to
}
if(label.isEmpty() || tooltip)
{
description += QString(" (") + QString::fromStdString(address) + QString(")");
label = address.empty() ? QString("n/a") : QString::fromStdString(address);
description += QString(" (") + label + QString(")");
}
return description;
}
Expand Down Expand Up @@ -417,10 +418,10 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress:
case TransactionRecord::Generated:
case TransactionRecord::SendToSelf:
return lookupAddress(wtx->address, tooltip) + watchAddress;
case TransactionRecord::SendToOther:
return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::SendToSelf:
default:
return tr("(n/a)") + watchAddress;
}
Expand All @@ -434,13 +435,12 @@ QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress:
case TransactionRecord::Generated:
case TransactionRecord::SendToSelf:
{
QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(wtx->address));
if(label.isEmpty())
return COLOR_BAREADDRESS;
} break;
case TransactionRecord::SendToSelf:
return COLOR_BAREADDRESS;
default:
break;
}
Expand Down