Skip to content

Commit 04eaa90

Browse files
committed
Add more clear interface for CoinControl.h regarding individual feerate
1 parent 3b35e48 commit 04eaa90

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/coincontrol.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class CCoinControl
1818
bool fAllowWatchOnly;
1919
//! Minimum absolute fee (not per kilobyte)
2020
CAmount nMinimumTotalFee;
21-
//! Feerate to use (0 = estimate fee with payTxFee fallback)
21+
//! Override estimated feerate
22+
bool fOverrideFeeRate;
23+
//! Feerate to use if overrideFeeRate is true
2224
CFeeRate nFeeRate;
2325

2426
CCoinControl()
@@ -34,6 +36,7 @@ class CCoinControl
3436
setSelected.clear();
3537
nMinimumTotalFee = 0;
3638
nFeeRate = CFeeRate(0);
39+
fOverrideFeeRate = false;
3740
}
3841

3942
bool HasSelected() const

src/wallet/rpcwallet.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2486,6 +2486,7 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp)
24862486
bool includeWatching = false;
24872487
bool lockUnspents = false;
24882488
CFeeRate feeRate = CFeeRate(0);
2489+
bool overrideEstimatedFeerate = false;
24892490

24902491
if (params.size() > 1) {
24912492
if (params[1].type() == UniValue::VBOOL) {
@@ -2518,7 +2519,10 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp)
25182519
lockUnspents = options["lockUnspents"].get_bool();
25192520

25202521
if (options.exists("feeRate"))
2522+
{
25212523
feeRate = CFeeRate(options["feeRate"].get_real());
2524+
overrideEstimatedFeerate = true;
2525+
}
25222526
}
25232527
}
25242528

@@ -2537,7 +2541,7 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp)
25372541
CAmount nFeeOut;
25382542
string strFailReason;
25392543

2540-
if(!pwalletMain->FundTransaction(tx, nFeeOut, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, changeAddress))
2544+
if(!pwalletMain->FundTransaction(tx, nFeeOut, overrideEstimatedFeerate, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, changeAddress))
25412545
throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason);
25422546

25432547
UniValue result(UniValue::VOBJ);

src/wallet/wallet.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,7 @@ bool CWallet::SelectCoins(const vector<COutput>& vAvailableCoins, const CAmount&
19181918
return res;
19191919
}
19201920

1921-
bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, const CFeeRate& specificFeeRate, int& nChangePosInOut, std::string& strFailReason, bool includeWatching, bool lockUnspents, const CTxDestination& destChange)
1921+
bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool overrideEstimatedFeeRate, const CFeeRate& specificFeeRate, int& nChangePosInOut, std::string& strFailReason, bool includeWatching, bool lockUnspents, const CTxDestination& destChange)
19221922
{
19231923
vector<CRecipient> vecSend;
19241924

@@ -1933,6 +1933,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, const C
19331933
coinControl.destChange = destChange;
19341934
coinControl.fAllowOtherInputs = true;
19351935
coinControl.fAllowWatchOnly = includeWatching;
1936+
coinControl.fOverrideFeeRate = overrideEstimatedFeeRate;
19361937
coinControl.nFeeRate = specificFeeRate;
19371938

19381939
BOOST_FOREACH(const CTxIn& txin, tx.vin)
@@ -2244,7 +2245,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
22442245
if (coinControl && nFeeNeeded > 0 && coinControl->nMinimumTotalFee > nFeeNeeded) {
22452246
nFeeNeeded = coinControl->nMinimumTotalFee;
22462247
}
2247-
if (coinControl && coinControl->nFeeRate > CFeeRate(0))
2248+
if (coinControl && coinControl->fOverrideFeeRate)
22482249
nFeeNeeded = coinControl->nFeeRate.GetFee(nBytes);
22492250

22502251
// If we made it here and we aren't even able to meet the relay fee on the next pass, give up

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
740740
* Insert additional inputs into the transaction by
741741
* calling CreateTransaction();
742742
*/
743-
bool FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, const CFeeRate& specificFeeRate, int& nChangePosInOut, std::string& strFailReason, bool includeWatching, bool lockUnspents, const CTxDestination& destChange = CNoDestination());
743+
bool FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool overrideEstimatedFeeRate, const CFeeRate& specificFeeRate, int& nChangePosInOut, std::string& strFailReason, bool includeWatching, bool lockUnspents, const CTxDestination& destChange = CNoDestination());
744744

745745
/**
746746
* Create a new transaction paying the recipients with a set of coins

0 commit comments

Comments
 (0)