Reject dust amounts during validation

Replaces the validation check for "amount == 0" with an isDust check,
so very small output amounts are caught before the wallet
is unlocked, a transaction is created, etc.
This commit is contained in:
Gavin Andresen
2013-08-08 13:09:07 +10:00
parent b986663ccd
commit 57d80467f1
3 changed files with 22 additions and 14 deletions

View File

@@ -101,20 +101,6 @@ bool SendCoinsEntry::validate()
// Check input validity
bool retval = true;
if(!ui->payAmount->validate())
{
retval = false;
}
else
{
if(ui->payAmount->value() <= 0)
{
// Cannot send 0 coins or less
ui->payAmount->setValid(false);
retval = false;
}
}
if(!ui->payTo->hasAcceptableInput() ||
(model && !model->validateAddress(ui->payTo->text())))
{
@@ -122,6 +108,17 @@ bool SendCoinsEntry::validate()
retval = false;
}
if(!ui->payAmount->validate())
{
retval = false;
}
// Reject dust outputs:
if (retval && GUIUtil::isDust(ui->payTo->text(), ui->payAmount->value())) {
ui->payAmount->setValid(false);
retval = false;
}
return retval;
}