aboutsummaryrefslogtreecommitdiff
path: root/src/qt/addresstablemodel.cpp
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@gmail.com>2018-04-10 16:27:40 -0400
committerJames O'Beirne <james.obeirne@gmail.com>2018-04-25 13:08:53 -0400
commit8cdcaee4c7b256c5c3b70f1cfb04a5fb547311cd (patch)
tree493a6b325a9d46beafa0444ad570a321022a34a5 /src/qt/addresstablemodel.cpp
parentc5b277033a72650c221084ec0f1326623a810fd0 (diff)
downloadbitcoin-8cdcaee4c7b256c5c3b70f1cfb04a5fb547311cd.tar.xz
[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.cpp28
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()),