Skip to content

Commit 88b8f0b

Browse files
committed
Simplify feebumper minimum fee code slightly
No change in behavior. Get rid of specifiedConfirmTarget if/else block and rename specifiedConfirmTarget and ignoreUserSetFee variables to ignoreGlobalPayTxFee.
1 parent 7e96ecf commit 88b8f0b

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

src/wallet/feebumper.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool CFeeBumper::preconditionChecks(const CWallet *pWallet, const CWalletTx& wtx
6666
return true;
6767
}
6868

69-
CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConfirmTarget, bool specifiedConfirmTarget, CAmount totalFee, bool newTxReplaceable)
69+
CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConfirmTarget, bool ignoreGlobalPayTxFee, CAmount totalFee, bool newTxReplaceable)
7070
:
7171
txid(std::move(txidIn)),
7272
nOldFee(0),
@@ -165,15 +165,7 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConf
165165
nNewFee = totalFee;
166166
nNewFeeRate = CFeeRate(totalFee, maxNewTxSize);
167167
} else {
168-
// if user specified a confirm target then don't consider any global payTxFee
169-
if (specifiedConfirmTarget) {
170-
nNewFee = CWallet::GetMinimumFee(maxNewTxSize, newConfirmTarget, mempool, ::feeEstimator, true);
171-
}
172-
// otherwise use the regular wallet logic to select payTxFee or default confirm target
173-
else {
174-
nNewFee = CWallet::GetMinimumFee(maxNewTxSize, newConfirmTarget, mempool, ::feeEstimator);
175-
}
176-
168+
nNewFee = CWallet::GetMinimumFee(maxNewTxSize, newConfirmTarget, mempool, ::feeEstimator, ignoreGlobalPayTxFee);
177169
nNewFeeRate = CFeeRate(nNewFee, maxNewTxSize);
178170

179171
// New fee rate must be at least old rate + minimum incremental relay rate

src/wallet/feebumper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ enum class BumpFeeResult
2424
class CFeeBumper
2525
{
2626
public:
27-
CFeeBumper(const CWallet *pWalletIn, const uint256 txidIn, int newConfirmTarget, bool specifiedConfirmTarget, CAmount totalFee, bool newTxReplaceable);
27+
CFeeBumper(const CWallet *pWalletIn, const uint256 txidIn, int newConfirmTarget, bool ignoreGlobalPayTxFee, CAmount totalFee, bool newTxReplaceable);
2828
BumpFeeResult getResult() const { return currentResult; }
2929
const std::vector<std::string>& getErrors() const { return vErrors; }
3030
CAmount getOldFee() const { return nOldFee; }

src/wallet/rpcwallet.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,7 +2834,7 @@ UniValue bumpfee(const JSONRPCRequest& request)
28342834
hash.SetHex(request.params[0].get_str());
28352835

28362836
// optional parameters
2837-
bool specifiedConfirmTarget = false;
2837+
bool ignoreGlobalPayTxFee = false;
28382838
int newConfirmTarget = nTxConfirmTarget;
28392839
CAmount totalFee = 0;
28402840
bool replaceable = true;
@@ -2851,7 +2851,10 @@ UniValue bumpfee(const JSONRPCRequest& request)
28512851
if (options.exists("confTarget") && options.exists("totalFee")) {
28522852
throw JSONRPCError(RPC_INVALID_PARAMETER, "confTarget and totalFee options should not both be set. Please provide either a confirmation target for fee estimation or an explicit total fee for the transaction.");
28532853
} else if (options.exists("confTarget")) {
2854-
specifiedConfirmTarget = true;
2854+
// If the user has explicitly set a confTarget in this rpc call,
2855+
// then override the default logic that uses the global payTxFee
2856+
// instead of the confirmation target.
2857+
ignoreGlobalPayTxFee = true;
28552858
newConfirmTarget = options["confTarget"].get_int();
28562859
if (newConfirmTarget <= 0) { // upper-bound will be checked by estimatefee/smartfee
28572860
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid confTarget (cannot be <= 0)");
@@ -2871,7 +2874,7 @@ UniValue bumpfee(const JSONRPCRequest& request)
28712874
LOCK2(cs_main, pwallet->cs_wallet);
28722875
EnsureWalletIsUnlocked(pwallet);
28732876

2874-
CFeeBumper feeBump(pwallet, hash, newConfirmTarget, specifiedConfirmTarget, totalFee, replaceable);
2877+
CFeeBumper feeBump(pwallet, hash, newConfirmTarget, ignoreGlobalPayTxFee, totalFee, replaceable);
28752878
BumpFeeResult res = feeBump.getResult();
28762879
if (res != BumpFeeResult::OK)
28772880
{

src/wallet/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,12 +2890,12 @@ CAmount CWallet::GetRequiredFee(unsigned int nTxBytes)
28902890
return std::max(minTxFee.GetFee(nTxBytes), ::minRelayTxFee.GetFee(nTxBytes));
28912891
}
28922892

2893-
CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool, const CBlockPolicyEstimator& estimator, bool ignoreUserSetFee)
2893+
CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool, const CBlockPolicyEstimator& estimator, bool ignoreGlobalPayTxFee)
28942894
{
28952895
// payTxFee is the user-set global for desired feerate
28962896
CAmount nFeeNeeded = payTxFee.GetFee(nTxBytes);
28972897
// User didn't set: use -txconfirmtarget to estimate...
2898-
if (nFeeNeeded == 0 || ignoreUserSetFee) {
2898+
if (nFeeNeeded == 0 || ignoreGlobalPayTxFee) {
28992899
int estimateFoundTarget = nConfirmTarget;
29002900
nFeeNeeded = estimator.estimateSmartFee(nConfirmTarget, &estimateFoundTarget, pool).GetFee(nTxBytes);
29012901
// ... unless we don't have enough mempool data for estimatefee, then use fallbackFee

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
959959
* Estimate the minimum fee considering user set parameters
960960
* and the required fee
961961
*/
962-
static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool, const CBlockPolicyEstimator& estimator, bool ignoreUserSetFee = false);
962+
static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool, const CBlockPolicyEstimator& estimator, bool ignoreGlobalPayTxFee = false);
963963
/**
964964
* Return the minimum required fee taking into account the
965965
* floating relay fee and user set minimum transaction fee

0 commit comments

Comments
 (0)