diff --git a/src/ContactsWidget.cpp b/src/ContactsWidget.cpp
index ecb67fb..7a32b46 100644
--- a/src/ContactsWidget.cpp
+++ b/src/ContactsWidget.cpp
@@ -126,11 +126,23 @@ void ContactsWidget::newContact(QString address, QString name)
name = dialog.getName();
bool addressValid = WalletManager::addressValid(address, m_wallet->nettype());
- if (!addressValid) {
+ bool nameIsAddress = WalletManager::addressValid(name, m_wallet->nettype());
+
+ if (addressValid && nameIsAddress) {
+ Utils::showError(this, "Unable to add contact", "Name can not be an address", {}, "add_contact");
+ return;
+ }
+
+ if (!addressValid && !nameIsAddress) {
Utils::showError(this, "Unable to add contact", "Invalid address", {"Use 'Tools -> Address checker' to check if the address is valid."}, "add_contact");
return;
}
+ if (!addressValid && nameIsAddress) {
+ // User accidentally swapped name and address, allow it
+ std::swap(address, name);
+ }
+
int num_addresses = m_wallet->addressBook()->count();
QString address_entry;
QString name_entry;
diff --git a/src/dialog/ContactsDialog.ui b/src/dialog/ContactsDialog.ui
index 1ec06bb..e8d176a 100644
--- a/src/dialog/ContactsDialog.ui
+++ b/src/dialog/ContactsDialog.ui
@@ -7,7 +7,7 @@
0
0
400
- 136
+ 131
@@ -17,13 +17,6 @@
-
-
-
-
- Address
-
-
-
- -
Name
@@ -31,10 +24,17 @@
-
-
+
+
+ -
+
+
+ Address
+
+
-
-
+