aboutsummaryrefslogtreecommitdiff
path: root/src/qt/editaddressdialog.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/editaddressdialog.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/editaddressdialog.cpp')
-rw-r--r--src/qt/editaddressdialog.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp
index 38411c499f..f26a31158e 100644
--- a/src/qt/editaddressdialog.cpp
+++ b/src/qt/editaddressdialog.cpp
@@ -109,7 +109,7 @@ void EditAddressDialog::accept()
break;
case AddressTableModel::DUPLICATE_ADDRESS:
QMessageBox::warning(this, windowTitle(),
- tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()),
+ getDuplicateAddressWarning(),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::WALLET_UNLOCK_FAILURE:
@@ -129,6 +129,25 @@ void EditAddressDialog::accept()
QDialog::accept();
}
+QString EditAddressDialog::getDuplicateAddressWarning() const
+{
+ QString dup_address = ui->addressEdit->text();
+ QString existing_label = model->labelForAddress(dup_address);
+ QString existing_purpose = model->purposeForAddress(dup_address);
+
+ if (existing_purpose == "receive" &&
+ (mode == NewSendingAddress || mode == EditSendingAddress)) {
+ return tr(
+ "Address \"%1\" already exists as a receiving address with label "
+ "\"%2\" and so cannot be added as a sending address."
+ ).arg(dup_address).arg(existing_label);
+ }
+ return tr(
+ "The entered address \"%1\" is already in the address book with "
+ "label \"%2\"."
+ ).arg(dup_address).arg(existing_label);
+}
+
QString EditAddressDialog::getAddress() const
{
return address;