mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
Check addresses in address book for validity
This commit is contained in:
parent
ebff5c40a2
commit
669b0a5835
@ -48,7 +48,6 @@ void AddressBookDialog::setModel(AddressTableModel *model)
|
|||||||
ui->receiveTableView->setModel(receive_model);
|
ui->receiveTableView->setModel(receive_model);
|
||||||
ui->receiveTableView->sortByColumn(0, Qt::AscendingOrder);
|
ui->receiveTableView->sortByColumn(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
|
|
||||||
// Send filter
|
// Send filter
|
||||||
QSortFilterProxyModel *send_model = new QSortFilterProxyModel(this);
|
QSortFilterProxyModel *send_model = new QSortFilterProxyModel(this);
|
||||||
send_model->setSourceModel(model);
|
send_model->setSourceModel(model);
|
||||||
@ -120,10 +119,7 @@ void AddressBookDialog::on_editButton_clicked()
|
|||||||
EditAddressDialog::EditReceivingAddress);
|
EditAddressDialog::EditReceivingAddress);
|
||||||
dlg.setModel(model);
|
dlg.setModel(model);
|
||||||
dlg.loadRow(selected.row());
|
dlg.loadRow(selected.row());
|
||||||
if(dlg.exec())
|
dlg.exec();
|
||||||
{
|
|
||||||
dlg.saveCurrentRow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressBookDialog::on_newAddressButton_clicked()
|
void AddressBookDialog::on_newAddressButton_clicked()
|
||||||
@ -133,10 +129,7 @@ void AddressBookDialog::on_newAddressButton_clicked()
|
|||||||
EditAddressDialog::NewSendingAddress :
|
EditAddressDialog::NewSendingAddress :
|
||||||
EditAddressDialog::NewReceivingAddress);
|
EditAddressDialog::NewReceivingAddress);
|
||||||
dlg.setModel(model);
|
dlg.setModel(model);
|
||||||
if(dlg.exec())
|
dlg.exec();
|
||||||
{
|
|
||||||
dlg.saveCurrentRow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressBookDialog::on_tabWidget_currentChanged(int index)
|
void AddressBookDialog::on_tabWidget_currentChanged(int index)
|
||||||
|
@ -263,3 +263,10 @@ void AddressTableModel::update()
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AddressTableModel::validateAddress(const QString &address)
|
||||||
|
{
|
||||||
|
uint160 hash160 = 0;
|
||||||
|
|
||||||
|
return AddressToHash160(address.toStdString(), hash160);
|
||||||
|
}
|
||||||
|
@ -44,6 +44,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
void updateList();
|
void updateList();
|
||||||
|
|
||||||
|
/* Check address for validity
|
||||||
|
*/
|
||||||
|
bool validateAddress(const QString &address);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CWallet *wallet;
|
CWallet *wallet;
|
||||||
AddressTablePriv *priv;
|
AddressTablePriv *priv;
|
||||||
|
@ -65,12 +65,6 @@ QString EditAddressDialog::saveCurrentRow()
|
|||||||
mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive,
|
mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive,
|
||||||
ui->labelEdit->text(),
|
ui->labelEdit->text(),
|
||||||
ui->addressEdit->text());
|
ui->addressEdit->text());
|
||||||
if(address.isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, windowTitle(),
|
|
||||||
tr("The address %1 is already in the address book.").arg(ui->addressEdit->text()),
|
|
||||||
QMessageBox::Ok, QMessageBox::Ok);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case EditReceivingAddress:
|
case EditReceivingAddress:
|
||||||
case EditSendingAddress:
|
case EditSendingAddress:
|
||||||
@ -82,3 +76,28 @@ QString EditAddressDialog::saveCurrentRow()
|
|||||||
}
|
}
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditAddressDialog::accept()
|
||||||
|
{
|
||||||
|
if(mode == NewSendingAddress || mode == EditSendingAddress)
|
||||||
|
{
|
||||||
|
// For sending addresses, check validity
|
||||||
|
// Not needed for receiving addresses, as those are generated
|
||||||
|
if(!model->validateAddress(ui->addressEdit->text()))
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, windowTitle(),
|
||||||
|
tr("The entered address \"%1\" is not a valid bitcoin address.").arg(ui->addressEdit->text()),
|
||||||
|
QMessageBox::Ok, QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(saveCurrentRow().isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, windowTitle(),
|
||||||
|
tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()),
|
||||||
|
QMessageBox::Ok, QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -29,9 +29,12 @@ public:
|
|||||||
|
|
||||||
void setModel(AddressTableModel *model);
|
void setModel(AddressTableModel *model);
|
||||||
void loadRow(int row);
|
void loadRow(int row);
|
||||||
QString saveCurrentRow();
|
|
||||||
|
void accept();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString saveCurrentRow();
|
||||||
|
|
||||||
Ui::EditAddressDialog *ui;
|
Ui::EditAddressDialog *ui;
|
||||||
QDataWidgetMapper *mapper;
|
QDataWidgetMapper *mapper;
|
||||||
Mode mode;
|
Mode mode;
|
||||||
|
Loading…
Reference in New Issue
Block a user