diff options
author | James O'Beirne <james.obeirne@gmail.com> | 2018-04-10 16:27:40 -0400 |
---|---|---|
committer | James O'Beirne <james.obeirne@gmail.com> | 2018-04-25 13:08:53 -0400 |
commit | 8cdcaee4c7b256c5c3b70f1cfb04a5fb547311cd (patch) | |
tree | 493a6b325a9d46beafa0444ad570a321022a34a5 /src/qt/addresstablemodel.cpp | |
parent | c5b277033a72650c221084ec0f1326623a810fd0 (diff) |
[qt] Display more helpful message when adding a send address has failed
Addresses #12796.
When we're unable to add a sending address to the address book because it
already exists as a receiving address, display a message indicating as much.
This should help avoid confusion about an address supposedly already in the
book but which isn't currently visible in the interface.
Diffstat (limited to 'src/qt/addresstablemodel.cpp')
-rw-r--r-- | src/qt/addresstablemodel.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index d85a13cd5b..f38e864b48 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -407,21 +407,31 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent return true; } -/* Look up label for address in address book, if not found return empty string. - */ QString AddressTableModel::labelForAddress(const QString &address) const { - { - CTxDestination destination = DecodeDestination(address.toStdString()); - std::string name; - if (walletModel->wallet().getAddress(destination, &name)) - { - return QString::fromStdString(name); - } + std::string name; + if (getAddressData(address, &name, /* purpose= */ nullptr)) { + return QString::fromStdString(name); + } + return QString(); +} + +QString AddressTableModel::purposeForAddress(const QString &address) const +{ + std::string purpose; + if (getAddressData(address, /* name= */ nullptr, &purpose)) { + return QString::fromStdString(purpose); } return QString(); } +bool AddressTableModel::getAddressData(const QString &address, + std::string* name, + std::string* purpose) const { + CTxDestination destination = DecodeDestination(address.toStdString()); + return walletModel->wallet().getAddress(destination, name, /* is_mine= */ nullptr, purpose); +} + int AddressTableModel::lookupAddress(const QString &address) const { QModelIndexList lst = match(index(0, Address, QModelIndex()), |