Remove direct bitcoin calls from qt/sendcoinsdialog.cpp

This commit is contained in:
Russell Yanofsky 2017-04-20 12:28:58 -04:00 committed by John Newbery
parent e872c93ee8
commit 56f33ca349
3 changed files with 17 additions and 9 deletions

View File

@ -216,7 +216,9 @@ class NodeImpl : public Node
return result;
}
CFeeRate getDustRelayFee() override { return ::dustRelayFee; }
CFeeRate getFallbackFee() override { CHECK_WALLET(return CWallet::fallbackFee); }
CFeeRate getPayTxFee() override { CHECK_WALLET(return ::payTxFee); }
void setPayTxFee(CFeeRate rate) override { CHECK_WALLET(::payTxFee = rate); }
UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) override
{
JSONRPCRequest req;

View File

@ -173,9 +173,15 @@ public:
//! Get dust relay fee.
virtual CFeeRate getDustRelayFee() = 0;
//! Get fallback fee.
virtual CFeeRate getFallbackFee() = 0;
//! Get pay tx fee.
virtual CFeeRate getPayTxFee() = 0;
//! Set pay tx fee.
virtual void setPayTxFee(CFeeRate rate) = 0;
//! Execute rpc command.
virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0;

View File

@ -18,7 +18,6 @@
#include <interface/node.h>
#include <key_io.h>
#include <wallet/coincontrol.h>
#include <validation.h> // mempool and minRelayTxFee
#include <ui_interface.h>
#include <txmempool.h>
#include <policy/fees.h>
@ -177,7 +176,7 @@ void SendCoinsDialog::setModel(WalletModel *_model)
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(updateSmartFeeLabel()));
connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
ui->customFee->setSingleStep(GetRequiredFee(1000));
ui->customFee->setSingleStep(model->node().getRequiredFee(1000));
updateFeeSectionControls();
updateMinFeeLabel();
updateSmartFeeLabel();
@ -575,7 +574,7 @@ void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn
msgParams.second = CClientUIInterface::MSG_ERROR;
break;
case WalletModel::AbsurdFee:
msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), maxTxFee));
msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->node().getMaxTxFee()));
break;
case WalletModel::PaymentRequestExpired:
msgParams.first = tr("Payment request expired.");
@ -638,7 +637,7 @@ void SendCoinsDialog::useAvailableBalance(SendCoinsEntry* entry)
void SendCoinsDialog::setMinimumFee()
{
ui->customFee->setValue(GetRequiredFee(1000));
ui->customFee->setValue(model->node().getRequiredFee(1000));
}
void SendCoinsDialog::updateFeeSectionControls()
@ -670,7 +669,7 @@ void SendCoinsDialog::updateMinFeeLabel()
{
if (model && model->getOptionsModel())
ui->checkBoxMinimumFee->setText(tr("Pay only the required fee of %1").arg(
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), GetRequiredFee(1000)) + "/kB")
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->node().getRequiredFee(1000)) + "/kB")
);
}
@ -694,12 +693,13 @@ void SendCoinsDialog::updateSmartFeeLabel()
CCoinControl coin_control;
updateCoinControlState(coin_control);
coin_control.m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels
FeeCalculation feeCalc;
CFeeRate feeRate = CFeeRate(GetMinimumFee(1000, coin_control, ::mempool, ::feeEstimator, &feeCalc));
int returned_target;
FeeReason reason;
CFeeRate feeRate = CFeeRate(model->node().getMinimumFee(1000, coin_control, &returned_target, &reason));
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
if (feeCalc.reason == FeeReason::FALLBACK) {
if (reason == FeeReason::FALLBACK) {
ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
ui->labelFeeEstimation->setText("");
ui->fallbackFeeWarningLabel->setVisible(true);
@ -711,7 +711,7 @@ void SendCoinsDialog::updateSmartFeeLabel()
else
{
ui->labelSmartFee2->hide();
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", feeCalc.returnedTarget));
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", returned_target));
ui->fallbackFeeWarningLabel->setVisible(false);
}