Created
March 30, 2018 14:17
-
-
Save jamesob/6bd9721e11431d636fd2b9f6399a45ef to your computer and use it in GitHub Desktop.
$ diff -u <(git diff master...pr/12830.1) <(git diff master...pr/12830.2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /proc/self/fd/13 2018-03-30 10:16:47.921893819 -0400 | |
+++ /proc/self/fd/14 2018-03-30 10:16:47.925893716 -0400 | |
@@ -130,7 +130,7 @@ | |
void emitDataChanged(int index); | |
diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp | |
-index 38411c499f..cc94eface0 100644 | |
+index 38411c499f..19eb5154f5 100644 | |
--- a/src/qt/editaddressdialog.cpp | |
+++ b/src/qt/editaddressdialog.cpp | |
@@ -109,7 +109,7 @@ void EditAddressDialog::accept() | |
@@ -142,20 +142,26 @@ | |
QMessageBox::Ok, QMessageBox::Ok); | |
break; | |
case AddressTableModel::WALLET_UNLOCK_FAILURE: | |
-@@ -129,6 +129,18 @@ void EditAddressDialog::accept() | |
+@@ -129,6 +129,24 @@ void EditAddressDialog::accept() | |
QDialog::accept(); | |
} | |
+QString EditAddressDialog::getDuplicateAddressWarning() const | |
+{ | |
-+ QString bad_addr_purpose = model->purposeForAddress(ui->addressEdit->text()); | |
-+ std::string fmt_str = "The entered address \"%1\" is already in the address book."; | |
++ QString dup_address = ui->addressEdit->text(); | |
++ QString existing_label = model->labelForAddress(dup_address); | |
++ QString existing_purpose = model->purposeForAddress(dup_address); | |
++ std::string fmt_str = | |
++ "The entered address \"%1\" is already in the address book with " | |
++ "label \"%2\"."; | |
+ | |
-+ if (bad_addr_purpose == "receive" && | |
++ if (existing_purpose == "receive" && | |
+ (mode == NewSendingAddress || mode == EditSendingAddress)) { | |
-+ fmt_str = "Receiving address \"%1\" cannot be added as a sending address."; | |
++ fmt_str = | |
++ "Address \"%1\" already exists as a receiving address with label " | |
++ "\"%2\" and so cannot be added as a sending address."; | |
+ } | |
-+ return tr(fmt_str.c_str()).arg(ui->addressEdit->text()); | |
++ return tr(fmt_str.c_str()).arg(ui->addressEdit->text()).arg(existing_label); | |
+} | |
+ | |
QString EditAddressDialog::getAddress() const | |
@@ -186,10 +192,10 @@ | |
Mode mode; | |
diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp | |
new file mode 100644 | |
-index 0000000000..f810f8c1d1 | |
+index 0000000000..4820fce7ae | |
--- /dev/null | |
+++ b/src/qt/test/addressbooktests.cpp | |
-@@ -0,0 +1,132 @@ | |
+@@ -0,0 +1,140 @@ | |
+#include <qt/test/addressbooktests.h> | |
+#include <qt/test/util.h> | |
+#include <test/test_bitcoin.h> | |
@@ -264,9 +270,11 @@ | |
+ | |
+ // Add a preexisting "receive" entry in the address book. | |
+ QString preexisting_r_address; | |
++ QString r_label("already here (r)"); | |
+ | |
+ // Add a preexisting "send" entry in the address book. | |
+ QString preexisting_s_address; | |
++ QString s_label("already here (s)"); | |
+ | |
+ // Define a new address (which should add to the address book successfully). | |
+ QString new_address; | |
@@ -277,8 +285,8 @@ | |
+ | |
+ { | |
+ LOCK(wallet.cs_wallet); | |
-+ wallet.SetAddressBook(r_key_dest, "already here (r)", "receive"); | |
-+ wallet.SetAddressBook(s_key_dest, "already here (s)", "send"); | |
++ wallet.SetAddressBook(r_key_dest, r_label.toStdString(), "receive"); | |
++ wallet.SetAddressBook(s_key_dest, s_label.toStdString(), "send"); | |
+ } | |
+ | |
+ auto check_addbook_size = [&wallet](int expected_size) { | |
@@ -298,18 +306,24 @@ | |
+ | |
+ EditAddressAndSubmit( | |
+ &editAddressDialog, QString("uhoh"), preexisting_r_address, | |
-+ QString("Receiving address \"%1\" cannot be added as a sending address.") | |
-+ .arg(preexisting_r_address)); | |
++ QString( | |
++ "Address \"%1\" already exists as a receiving address with label " | |
++ "\"%2\" and so cannot be added as a sending address." | |
++ ).arg(preexisting_r_address).arg(r_label)); | |
+ | |
+ check_addbook_size(2); | |
+ | |
+ EditAddressAndSubmit( | |
+ &editAddressDialog, QString("uhoh, different"), preexisting_s_address, | |
-+ QString("The entered address \"%1\" is already in the address book.") | |
-+ .arg(preexisting_s_address)); | |
++ QString( | |
++ "The entered address \"%1\" is already in the address book with " | |
++ "label \"%2\"." | |
++ ).arg(preexisting_s_address).arg(s_label)); | |
+ | |
+ check_addbook_size(2); | |
+ | |
++ // Submit a new address which should add successfully - we expect the | |
++ // warning message to be blank. | |
+ EditAddressAndSubmit( | |
+ &editAddressDialog, QString("new"), new_address, QString("")); | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment