Skip to content

Commit f0bf33d

Browse files
committed
Change default fee estimation mode.
Fee estimates will default to be non-conservative if the transaction in question is opt-in-RBF.
1 parent e0738e3 commit f0bf33d

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

src/qt/coincontroldialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
490490
else nBytesInputs += 148;
491491
}
492492

493-
bool conservative_estimate = CalculateEstimateType(FeeEstimateMode::UNSET);
493+
bool conservative_estimate = CalculateEstimateType(FeeEstimateMode::UNSET, coinControl->signalRbf);
494494

495495
// calculation
496496
if (nQuantity > 0)

src/qt/sendcoinsdialog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ void SendCoinsDialog::setModel(WalletModel *_model)
166166
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(updateFeeSectionControls()));
167167
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(updateGlobalFeeVariables()));
168168
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
169+
connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(updateSmartFeeLabel()));
170+
connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
169171
ui->customFee->setSingleStep(CWallet::GetRequiredFee(1000));
170172
updateFeeSectionControls();
171173
updateMinFeeLabel();
@@ -652,7 +654,7 @@ void SendCoinsDialog::updateSmartFeeLabel()
652654

653655
int nBlocksToConfirm = ui->sliderSmartFee->maximum() - ui->sliderSmartFee->value() + 2;
654656
FeeCalculation feeCalc;
655-
bool conservative_estimate = CalculateEstimateType(FeeEstimateMode::UNSET);
657+
bool conservative_estimate = CalculateEstimateType(FeeEstimateMode::UNSET, ui->optInRBF->isChecked());
656658
CFeeRate feeRate = ::feeEstimator.estimateSmartFee(nBlocksToConfirm, &feeCalc, ::mempool, conservative_estimate);
657659
if (feeRate <= CFeeRate(0)) // not enough data => minfee
658660
{
@@ -828,6 +830,7 @@ void SendCoinsDialog::coinControlUpdateLabels()
828830
} else {
829831
CoinControlDialog::coinControl->nConfirmTarget = model->getDefaultConfirmTarget();
830832
}
833+
CoinControlDialog::coinControl->signalRbf = ui->optInRBF->isChecked();
831834

832835
for(int i = 0; i < ui->entries->count(); ++i)
833836
{

src/wallet/feebumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConf
165165
nNewFee = totalFee;
166166
nNewFeeRate = CFeeRate(totalFee, maxNewTxSize);
167167
} else {
168-
bool conservative_estimate = CalculateEstimateType(FeeEstimateMode::UNSET);
168+
bool conservative_estimate = CalculateEstimateType(FeeEstimateMode::UNSET, newTxReplaceable);
169169
nNewFee = CWallet::GetMinimumFee(maxNewTxSize, newConfirmTarget, mempool, ::feeEstimator, nullptr /* FeeCalculation */, ignoreGlobalPayTxFee, conservative_estimate);
170170
nNewFeeRate = CFeeRate(nNewFee, maxNewTxSize);
171171

src/wallet/wallet.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,7 +2725,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
27252725
currentConfirmationTarget = coinControl->nConfirmTarget;
27262726

27272727
// Allow to override the default fee estimate mode over the CoinControl instance
2728-
bool conservative_estimate = CalculateEstimateType(coinControl ? coinControl->m_fee_mode : FeeEstimateMode::UNSET);
2728+
bool conservative_estimate = CalculateEstimateType(coinControl ? coinControl->m_fee_mode : FeeEstimateMode::UNSET, rbf);
27292729

27302730
CAmount nFeeNeeded = GetMinimumFee(nBytes, currentConfirmationTarget, ::mempool, ::feeEstimator, &feeCalc, false /* ignoreGlobalPayTxFee */, conservative_estimate);
27312731
if (coinControl && coinControl->fOverrideFeeRate)
@@ -4158,9 +4158,10 @@ bool CMerkleTx::AcceptToMemoryPool(const CAmount& nAbsurdFee, CValidationState&
41584158
return ::AcceptToMemoryPool(mempool, state, tx, true, NULL, NULL, false, nAbsurdFee);
41594159
}
41604160

4161-
bool CalculateEstimateType(FeeEstimateMode mode) {
4161+
bool CalculateEstimateType(FeeEstimateMode mode, bool opt_in_rbf) {
41624162
switch (mode) {
41634163
case FeeEstimateMode::UNSET:
4164+
return !opt_in_rbf; // Allow for lower fees if RBF is an option
41644165
case FeeEstimateMode::CONSERVATIVE:
41654166
return true;
41664167
case FeeEstimateMode::ECONOMICAL:

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,6 @@ bool CWallet::DummySignTx(CMutableTransaction &txNew, const ContainerType &coins
12131213
return true;
12141214
}
12151215

1216-
bool CalculateEstimateType(FeeEstimateMode mode);
1216+
bool CalculateEstimateType(FeeEstimateMode mode, bool opt_in_rbf);
12171217

12181218
#endif // BITCOIN_WALLET_WALLET_H

0 commit comments

Comments
 (0)