Skip to content

Commit 56f33ca

Browse files
ryanofskyjnewbery
authored andcommitted
Remove direct bitcoin calls from qt/sendcoinsdialog.cpp
1 parent e872c93 commit 56f33ca

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/interface/node.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ class NodeImpl : public Node
216216
return result;
217217
}
218218
CFeeRate getDustRelayFee() override { return ::dustRelayFee; }
219+
CFeeRate getFallbackFee() override { CHECK_WALLET(return CWallet::fallbackFee); }
219220
CFeeRate getPayTxFee() override { CHECK_WALLET(return ::payTxFee); }
221+
void setPayTxFee(CFeeRate rate) override { CHECK_WALLET(::payTxFee = rate); }
220222
UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) override
221223
{
222224
JSONRPCRequest req;

src/interface/node.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,15 @@ class Node
173173
//! Get dust relay fee.
174174
virtual CFeeRate getDustRelayFee() = 0;
175175

176+
//! Get fallback fee.
177+
virtual CFeeRate getFallbackFee() = 0;
178+
176179
//! Get pay tx fee.
177180
virtual CFeeRate getPayTxFee() = 0;
178181

182+
//! Set pay tx fee.
183+
virtual void setPayTxFee(CFeeRate rate) = 0;
184+
179185
//! Execute rpc command.
180186
virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0;
181187

src/qt/sendcoinsdialog.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <interface/node.h>
1919
#include <key_io.h>
2020
#include <wallet/coincontrol.h>
21-
#include <validation.h> // mempool and minRelayTxFee
2221
#include <ui_interface.h>
2322
#include <txmempool.h>
2423
#include <policy/fees.h>
@@ -177,7 +176,7 @@ void SendCoinsDialog::setModel(WalletModel *_model)
177176
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
178177
connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(updateSmartFeeLabel()));
179178
connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
180-
ui->customFee->setSingleStep(GetRequiredFee(1000));
179+
ui->customFee->setSingleStep(model->node().getRequiredFee(1000));
181180
updateFeeSectionControls();
182181
updateMinFeeLabel();
183182
updateSmartFeeLabel();
@@ -575,7 +574,7 @@ void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn
575574
msgParams.second = CClientUIInterface::MSG_ERROR;
576575
break;
577576
case WalletModel::AbsurdFee:
578-
msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), maxTxFee));
577+
msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->node().getMaxTxFee()));
579578
break;
580579
case WalletModel::PaymentRequestExpired:
581580
msgParams.first = tr("Payment request expired.");
@@ -638,7 +637,7 @@ void SendCoinsDialog::useAvailableBalance(SendCoinsEntry* entry)
638637

639638
void SendCoinsDialog::setMinimumFee()
640639
{
641-
ui->customFee->setValue(GetRequiredFee(1000));
640+
ui->customFee->setValue(model->node().getRequiredFee(1000));
642641
}
643642

644643
void SendCoinsDialog::updateFeeSectionControls()
@@ -670,7 +669,7 @@ void SendCoinsDialog::updateMinFeeLabel()
670669
{
671670
if (model && model->getOptionsModel())
672671
ui->checkBoxMinimumFee->setText(tr("Pay only the required fee of %1").arg(
673-
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), GetRequiredFee(1000)) + "/kB")
672+
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->node().getRequiredFee(1000)) + "/kB")
674673
);
675674
}
676675

@@ -694,12 +693,13 @@ void SendCoinsDialog::updateSmartFeeLabel()
694693
CCoinControl coin_control;
695694
updateCoinControlState(coin_control);
696695
coin_control.m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels
697-
FeeCalculation feeCalc;
698-
CFeeRate feeRate = CFeeRate(GetMinimumFee(1000, coin_control, ::mempool, ::feeEstimator, &feeCalc));
696+
int returned_target;
697+
FeeReason reason;
698+
CFeeRate feeRate = CFeeRate(model->node().getMinimumFee(1000, coin_control, &returned_target, &reason));
699699

700700
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
701701

702-
if (feeCalc.reason == FeeReason::FALLBACK) {
702+
if (reason == FeeReason::FALLBACK) {
703703
ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
704704
ui->labelFeeEstimation->setText("");
705705
ui->fallbackFeeWarningLabel->setVisible(true);
@@ -711,7 +711,7 @@ void SendCoinsDialog::updateSmartFeeLabel()
711711
else
712712
{
713713
ui->labelSmartFee2->hide();
714-
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", feeCalc.returnedTarget));
714+
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", returned_target));
715715
ui->fallbackFeeWarningLabel->setVisible(false);
716716
}
717717

0 commit comments

Comments
 (0)