Remove direct bitcoin access from qt/guiutil.cpp

This commit is contained in:
Russell Yanofsky 2017-04-18 17:06:13 -04:00 committed by John Newbery
parent 58845587e1
commit e872c93ee8
5 changed files with 13 additions and 8 deletions

View file

@ -13,7 +13,7 @@
#include <chainparams.h>
#include <primitives/transaction.h>
#include <key_io.h>
#include <init.h>
#include <interface/node.h>
#include <policy/policy.h>
#include <protocol.h>
#include <script/script.h>
@ -232,12 +232,12 @@ QString formatBitcoinURI(const SendCoinsRecipient &info)
return ret;
}
bool isDust(const QString& address, const CAmount& amount)
bool isDust(interface::Node& node, const QString& address, const CAmount& amount)
{
CTxDestination dest = DecodeDestination(address.toStdString());
CScript script = GetScriptForDestination(dest);
CTxOut txOut(amount, script);
return IsDust(txOut, ::dustRelayFee);
return IsDust(txOut, node.getDustRelayFee());
}
QString HtmlEscape(const QString& str, bool fMultiLine)

View file

@ -20,6 +20,11 @@
class QValidatedLineEdit;
class SendCoinsRecipient;
namespace interface
{
class Node;
}
QT_BEGIN_NAMESPACE
class QAbstractItemView;
class QDateTime;
@ -49,7 +54,7 @@ namespace GUIUtil
QString formatBitcoinURI(const SendCoinsRecipient &info);
// Returns true if given address+amount meets "dust" definition
bool isDust(const QString& address, const CAmount& amount);
bool isDust(interface::Node& node, const QString& address, const CAmount& amount);
// HTML escaping for rich text controls
QString HtmlEscape(const QString& str, bool fMultiLine=false);

View file

@ -226,7 +226,7 @@ void SendCoinsDialog::on_sendButton_clicked()
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if(entry)
{
if(entry->validate())
if(entry->validate(model->node()))
{
recipients.append(entry->getValue());
}

View file

@ -127,7 +127,7 @@ void SendCoinsEntry::useAvailableBalanceClicked()
Q_EMIT useAvailableBalance(this);
}
bool SendCoinsEntry::validate()
bool SendCoinsEntry::validate(interface::Node& node)
{
if (!model)
return false;
@ -158,7 +158,7 @@ bool SendCoinsEntry::validate()
}
// Reject dust outputs:
if (retval && GUIUtil::isDust(ui->payTo->text(), ui->payAmount->value())) {
if (retval && GUIUtil::isDust(node, ui->payTo->text(), ui->payAmount->value())) {
ui->payAmount->setValid(false);
retval = false;
}

View file

@ -30,7 +30,7 @@ public:
~SendCoinsEntry();
void setModel(WalletModel *model);
bool validate();
bool validate(interface::Node& node);
SendCoinsRecipient getValue();
/** Return whether the entry is still empty and unedited */