|
|
@ -6,17 +6,31 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <QApplication> |
|
|
|
#include <QApplication> |
|
|
|
#include <QClipboard> |
|
|
|
#include <QClipboard> |
|
|
|
|
|
|
|
#include <QMessageBox> |
|
|
|
|
|
|
|
#include <QLocale> |
|
|
|
|
|
|
|
|
|
|
|
#include "base58.h" |
|
|
|
#include "base58.h" |
|
|
|
|
|
|
|
|
|
|
|
SendCoinsDialog::SendCoinsDialog(QWidget *parent) : |
|
|
|
SendCoinsDialog::SendCoinsDialog(QWidget *parent, const QString &address) : |
|
|
|
QDialog(parent), |
|
|
|
QDialog(parent), |
|
|
|
ui(new Ui::SendCoinsDialog) |
|
|
|
ui(new Ui::SendCoinsDialog) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ui->setupUi(this); |
|
|
|
ui->setupUi(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set up validators */ |
|
|
|
ui->payTo->setMaxLength(BitcoinAddressValidator::MaxAddressLength); |
|
|
|
ui->payTo->setMaxLength(BitcoinAddressValidator::MaxAddressLength); |
|
|
|
ui->payTo->setValidator(new BitcoinAddressValidator(this)); |
|
|
|
ui->payTo->setValidator(new BitcoinAddressValidator(this)); |
|
|
|
ui->payAmount->setValidator(new QDoubleValidator(this)); |
|
|
|
QDoubleValidator *amountValidator = new QDoubleValidator(this); |
|
|
|
|
|
|
|
amountValidator->setDecimals(8); |
|
|
|
|
|
|
|
amountValidator->setBottom(0.0); |
|
|
|
|
|
|
|
ui->payAmount->setValidator(amountValidator); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set initial address if provided */ |
|
|
|
|
|
|
|
if(!address.isEmpty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ui->payTo->setText(address); |
|
|
|
|
|
|
|
ui->payAmount->setFocus(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SendCoinsDialog::~SendCoinsDialog() |
|
|
|
SendCoinsDialog::~SendCoinsDialog() |
|
|
@ -28,14 +42,31 @@ void SendCoinsDialog::on_sendButton_clicked() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QByteArray payTo = ui->payTo->text().toUtf8(); |
|
|
|
QByteArray payTo = ui->payTo->text().toUtf8(); |
|
|
|
uint160 payToHash = 0; |
|
|
|
uint160 payToHash = 0; |
|
|
|
if(AddressToHash160(payTo.constData(), payToHash)) |
|
|
|
double payAmount = 0.0; |
|
|
|
|
|
|
|
bool valid = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!AddressToHash160(payTo.constData(), payToHash)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
accept(); |
|
|
|
QMessageBox::warning(this, tr("Warning"), |
|
|
|
|
|
|
|
tr("The recepient address is not valid, please recheck."), |
|
|
|
|
|
|
|
QMessageBox::Ok, |
|
|
|
|
|
|
|
QMessageBox::Ok); |
|
|
|
|
|
|
|
ui->payTo->setFocus(); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
payAmount = QLocale::system().toDouble(ui->payAmount->text(), &valid); |
|
|
|
|
|
|
|
if(!valid || payAmount <= 0.0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
QMessageBox::warning(this, tr("Warning"), |
|
|
|
|
|
|
|
tr("The amount to pay must be a valid number larger than 0."), |
|
|
|
|
|
|
|
QMessageBox::Ok, |
|
|
|
|
|
|
|
QMessageBox::Ok); |
|
|
|
|
|
|
|
ui->payAmount->setFocus(); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: send command to core, once this succeeds do accept() */ |
|
|
|
|
|
|
|
accept(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SendCoinsDialog::on_pasteButton_clicked() |
|
|
|
void SendCoinsDialog::on_pasteButton_clicked() |
|
|
|