diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2017-04-20 12:28:58 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2018-04-04 16:52:40 -0400 |
commit | 56f33ca349b3721a15fce3bf0b6d4fd7fd788970 (patch) | |
tree | 61c2199706747b7d2bb9581de073b09162e21b32 | |
parent | e872c93ee87477130fb877da1a536b4c693bbab9 (diff) |
Remove direct bitcoin calls from qt/sendcoinsdialog.cpp
-rw-r--r-- | src/interface/node.cpp | 2 | ||||
-rw-r--r-- | src/interface/node.h | 6 | ||||
-rw-r--r-- | src/qt/sendcoinsdialog.cpp | 18 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/interface/node.cpp b/src/interface/node.cpp index a8ed275dc5..f04da4e176 100644 --- a/src/interface/node.cpp +++ b/src/interface/node.cpp @@ -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; diff --git a/src/interface/node.h b/src/interface/node.h index c73f45a1b0..6ae7f9e46c 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -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; diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 2363154115..498bbf5466 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -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); } |