Remove direct bitcoin access from qt/guiutil.cpp
This commit is contained in:
parent
58845587e1
commit
e872c93ee8
5 changed files with 13 additions and 8 deletions
|
@ -13,7 +13,7 @@
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
#include <key_io.h>
|
#include <key_io.h>
|
||||||
#include <init.h>
|
#include <interface/node.h>
|
||||||
#include <policy/policy.h>
|
#include <policy/policy.h>
|
||||||
#include <protocol.h>
|
#include <protocol.h>
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
|
@ -232,12 +232,12 @@ QString formatBitcoinURI(const SendCoinsRecipient &info)
|
||||||
return ret;
|
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());
|
CTxDestination dest = DecodeDestination(address.toStdString());
|
||||||
CScript script = GetScriptForDestination(dest);
|
CScript script = GetScriptForDestination(dest);
|
||||||
CTxOut txOut(amount, script);
|
CTxOut txOut(amount, script);
|
||||||
return IsDust(txOut, ::dustRelayFee);
|
return IsDust(txOut, node.getDustRelayFee());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HtmlEscape(const QString& str, bool fMultiLine)
|
QString HtmlEscape(const QString& str, bool fMultiLine)
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
class QValidatedLineEdit;
|
class QValidatedLineEdit;
|
||||||
class SendCoinsRecipient;
|
class SendCoinsRecipient;
|
||||||
|
|
||||||
|
namespace interface
|
||||||
|
{
|
||||||
|
class Node;
|
||||||
|
}
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAbstractItemView;
|
class QAbstractItemView;
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
|
@ -49,7 +54,7 @@ namespace GUIUtil
|
||||||
QString formatBitcoinURI(const SendCoinsRecipient &info);
|
QString formatBitcoinURI(const SendCoinsRecipient &info);
|
||||||
|
|
||||||
// Returns true if given address+amount meets "dust" definition
|
// 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
|
// HTML escaping for rich text controls
|
||||||
QString HtmlEscape(const QString& str, bool fMultiLine=false);
|
QString HtmlEscape(const QString& str, bool fMultiLine=false);
|
||||||
|
|
|
@ -226,7 +226,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||||
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
|
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
|
||||||
if(entry)
|
if(entry)
|
||||||
{
|
{
|
||||||
if(entry->validate())
|
if(entry->validate(model->node()))
|
||||||
{
|
{
|
||||||
recipients.append(entry->getValue());
|
recipients.append(entry->getValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ void SendCoinsEntry::useAvailableBalanceClicked()
|
||||||
Q_EMIT useAvailableBalance(this);
|
Q_EMIT useAvailableBalance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SendCoinsEntry::validate()
|
bool SendCoinsEntry::validate(interface::Node& node)
|
||||||
{
|
{
|
||||||
if (!model)
|
if (!model)
|
||||||
return false;
|
return false;
|
||||||
|
@ -158,7 +158,7 @@ bool SendCoinsEntry::validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reject dust outputs:
|
// 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);
|
ui->payAmount->setValid(false);
|
||||||
retval = false;
|
retval = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
~SendCoinsEntry();
|
~SendCoinsEntry();
|
||||||
|
|
||||||
void setModel(WalletModel *model);
|
void setModel(WalletModel *model);
|
||||||
bool validate();
|
bool validate(interface::Node& node);
|
||||||
SendCoinsRecipient getValue();
|
SendCoinsRecipient getValue();
|
||||||
|
|
||||||
/** Return whether the entry is still empty and unedited */
|
/** Return whether the entry is still empty and unedited */
|
||||||
|
|
Loading…
Reference in a new issue