Skip to content

Commit

Permalink
Fix for bitcoin#872 - Unable to edit address or label (bitcoin#898)
Browse files Browse the repository at this point in the history
* Dispaly either the label or the address

If the user is entering a label it is clear they do not
want to see the address. This is the whole point of labelling
and address for the list of transactions.

* Fix the editing of an entry in the Transaction list view.

Previously when trying to edit an entry that had already
been edited, the "enter new address" dialog would appear
rather than the "edit address" dialog.  This was caused by
the the label being returned rather than the address and
as a result the address would not be found in the list, causing
the wrong dialog to open.

* Remove unnecessary boost includes and foreach loops
  • Loading branch information
ptschip authored and gandrewstone committed Jan 11, 2018
1 parent a078eb1 commit 43899c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include "dstencode.h"
#include "wallet/wallet.h"

#include <boost/foreach.hpp>

#include <QDateTime>
#include <QDebug>
#include <QFont>
Expand Down
8 changes: 3 additions & 5 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#include <stdint.h>

#include <boost/foreach.hpp>

/* Return positive answer if transaction should be shown in list.
*/
bool TransactionRecord::showTransaction(const CWalletTx &wtx)
Expand Down Expand Up @@ -48,7 +46,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
// Credit
//
std::string labelPublic = "";
BOOST_FOREACH (const CTxOut &txout, wtx.vout)
for (const CTxOut &txout : wtx.vout)
{
isminetype mine = wallet->IsMine(txout);
if (mine)
Expand Down Expand Up @@ -100,7 +98,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
{
bool involvesWatchAddress = false;
isminetype fAllToMe = ISMINE_SPENDABLE;
BOOST_FOREACH (const CTxOut &txout, wtx.vout)
for (const CTxOut &txout : wtx.vout)
{
isminetype mine = wallet->IsMine(txout);
if (mine & ISMINE_WATCH_ONLY)
Expand All @@ -113,7 +111,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
AddressList listAllAddresses;

isminetype fAllFromMe = ISMINE_SPENDABLE;
BOOST_FOREACH (const CTxIn &txin, wtx.vin)
for (const CTxIn &txin : wtx.vin)
{
isminetype mine = wallet->IsMine(txin);
if (mine & ISMINE_WATCH_ONLY)
Expand Down
10 changes: 4 additions & 6 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include <QIcon>
#include <QList>

#include <boost/foreach.hpp>

// Amount column is right-aligned it contains numbers
static int column_alignments[] = {
Qt::AlignLeft | Qt::AlignVCenter, /* status */
Expand Down Expand Up @@ -408,7 +406,7 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b

/* Get all the addresses so the user can filter for any of them */
std::string addressList = "";
BOOST_FOREACH (const PAIRTYPE(std::string, CScript) & addr, wtx->addresses)
for (const std::pair<std::string, CScript> &addr : wtx->addresses)
{
std::string nextAddress = boost::replace_all_copy(addr.first, "\n", " ");
// ensure list isn't prefixed by a space
Expand All @@ -421,7 +419,7 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
if (label == "")
return QString::fromStdString(addressList) + watchAddress;
else
return label + " " + QString::fromStdString(addressList) + watchAddress;
return label + watchAddress;
}

QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
Expand Down Expand Up @@ -531,7 +529,7 @@ QString TransactionTableModel::pickLabelWithAddress(AddressList listAddresses, s
{
/* returns the first address wiith a label or the last address on the list */
QString label = "";
BOOST_FOREACH (const PAIRTYPE(std::string, CScript) & addr, listAddresses)
for (const std::pair<std::string, CScript> &addr : listAddresses)
{
address = addr.first;
label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(address));
Expand Down Expand Up @@ -632,7 +630,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return priv->describe(rec, walletModel->getOptionsModel()->getDisplayUnit(),
walletModel->getAddressTableModel()->labelForFreeze(QString::fromStdString(address)));
case AddressRole:
return formatTxToAddress(rec, false);
return QString::fromStdString(address);
case LabelRole:
return label;
case AmountRole:
Expand Down

0 comments on commit 43899c0

Please sign in to comment.