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;
<x>0</x>
<y>0</y>
<width>400</width>
- <height>136</height>
+ <height>131</height>
</rect>
</property>
<property name="windowTitle">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
- <widget class="QLabel" name="label_2">
+ <widget class="QLabel" name="label_3">
<property name="text">
- <string>Address</string>
+ <string>Name</string>
</property>
</widget>
</item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEdit_name"/>
+ </item>
<item row="1" column="0">
- <widget class="QLabel" name="label_3">
+ <widget class="QLabel" name="label_2">
<property name="text">
- <string>Name</string>
+ <string>Address</string>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="lineEdit_address"/>
- </item>
<item row="1" column="1">
- <widget class="QLineEdit" name="lineEdit_name"/>
+ <widget class="QLineEdit" name="lineEdit_address"/>
</item>
</layout>
</item>