diff --git a/src/interfaces/node.h b/src/interfaces/node.h --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -156,18 +156,30 @@ virtual bool getNetworkActive() = 0; //! Get minimum fee. + virtual Amount getMinimumFee(unsigned int tx_bytes) = 0; + + //! Get minimum fee with coin control. virtual Amount getMinimumFee(unsigned int tx_bytes, const CCoinControl &coin_control) = 0; //! Get max tx fee. virtual Amount getMaxTxFee() = 0; + //! Estimate smart fee. + virtual CFeeRate estimateSmartFee() = 0; + //! 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(Config &config, const std::string &command, const UniValue ¶ms, diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp --- a/src/interfaces/node.cpp +++ b/src/interfaces/node.cpp @@ -212,6 +212,11 @@ bool getNetworkActive() override { return g_connman && g_connman->GetNetworkActive(); } + Amount getMinimumFee(unsigned int tx_bytes) override { + Amount result; + CHECK_WALLET(result = GetMinimumFee(tx_bytes, g_mempool)); + return result; + } Amount getMinimumFee(unsigned int tx_bytes, const CCoinControl &coin_control) override { Amount result; @@ -220,8 +225,15 @@ return result; } Amount getMaxTxFee() override { return ::maxTxFee; } + CFeeRate estimateSmartFee() override { return g_mempool.estimateFee(); } 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(Config &config, const std::string &command, const UniValue ¶ms, const std::string &uri) override { diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -19,7 +19,6 @@ #include #include #include -#include // mempool and minRelayTxFee #include #include #include @@ -206,7 +205,7 @@ connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels())); - ui->customFee->setSingleStep(GetMinimumFee(1000, g_mempool)); + ui->customFee->setSingleStep(model->node().getMinimumFee(1000)); updateFeeSectionControls(); updateMinFeeLabel(); updateSmartFeeLabel(); @@ -602,7 +601,8 @@ msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.") .arg(BitcoinUnits::formatWithUnit( - model->getOptionsModel()->getDisplayUnit(), maxTxFee)); + model->getOptionsModel()->getDisplayUnit(), + model->node().getMaxTxFee())); break; case WalletModel::PaymentRequestExpired: msgParams.first = tr("Payment request expired."); @@ -663,7 +663,7 @@ void SendCoinsDialog::setMinimumFee() { ui->radioCustomPerKilobyte->setChecked(true); - ui->customFee->setValue(GetMinimumFee(1000, g_mempool)); + ui->customFee->setValue(model->node().getMinimumFee(1000)); } void SendCoinsDialog::updateFeeSectionControls() { @@ -701,7 +701,7 @@ tr("Pay only the required fee of %1") .arg(BitcoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), - GetMinimumFee(1000, g_mempool)) + + model->node().getMinimumFee(1000)) + "/kB")); } } @@ -719,12 +719,12 @@ return; } - CFeeRate feeRate = g_mempool.estimateFee(); + CFeeRate feeRate = model->node().estimateSmartFee(); ui->labelSmartFee->setText( BitcoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), - std::max(feeRate.GetFeePerK(), GetMinimumFee(1000, g_mempool))) + + std::max(feeRate.GetFeePerK(), model->node().getMinimumFee(1000))) + "/kB"); // not enough data => minfee if (feeRate <= CFeeRate(Amount::zero())) {