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 xdustinface
parent 155324e867
commit e4e00cbbdd
5 changed files with 13 additions and 8 deletions

View File

@ -14,7 +14,7 @@
#include <qt/walletmodel.h>
#include <primitives/transaction.h>
#include <init.h>
#include <interface/node.h>
#include <policy/policy.h>
#include <protocol.h>
#include <script/script.h>
@ -457,12 +457,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

@ -23,6 +23,11 @@ class QValidatedLineEdit;
class OptionsModel;
class SendCoinsRecipient;
namespace interface
{
class Node;
}
QT_BEGIN_NAMESPACE
class QAbstractButton;
class QAbstractItemView;
@ -116,7 +121,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

@ -263,7 +263,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

@ -132,7 +132,7 @@ void SendCoinsEntry::useAvailableBalanceClicked()
Q_EMIT useAvailableBalance(this);
}
bool SendCoinsEntry::validate()
bool SendCoinsEntry::validate(interface::Node& node)
{
if (!model)
return false;
@ -163,7 +163,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

@ -29,7 +29,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 */