mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-20 14:05:23 +01:00
Allow the long term feerate to be configured, default of 10 sat/vb
The long term feerate is really the highest feerate that the user is comfortable with making consolidatory transactions. This is should thus be something that can be configured by the user via a new startup option -consolidatefeerate. The default value is 10 sat/vbyte, chosen arbitrarily (it seems like a reasonable number).
This commit is contained in:
parent
eb09c26724
commit
54de7b4746
5 changed files with 22 additions and 5 deletions
|
@ -28,6 +28,7 @@ void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const
|
|||
"-addresstype",
|
||||
"-avoidpartialspends",
|
||||
"-changetype",
|
||||
"-consolidatefeerate=<amt>",
|
||||
"-disablewallet",
|
||||
"-discardfee=<amt>",
|
||||
"-fallbackfee=<amt>",
|
||||
|
|
|
@ -45,6 +45,7 @@ void WalletInit::AddWalletOptions(ArgsManager& argsman) const
|
|||
argsman.AddArg("-addresstype", strprintf("What type of addresses to use (\"legacy\", \"p2sh-segwit\", or \"bech32\", default: \"%s\")", FormatOutputType(DEFAULT_ADDRESS_TYPE)), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
argsman.AddArg("-avoidpartialspends", strprintf("Group outputs by address, selecting many (possibly all) or none, instead of selecting on a per-output basis. Privacy is improved as addresses are mostly swept with fewer transactions and outputs are aggregated in clean change addresses. It may result in higher fees due to less optimal coin selection caused by this added limitation and possibly a larger-than-necessary number of inputs being used. Always enabled for wallets with \"avoid_reuse\" enabled, otherwise default: %u.", DEFAULT_AVOIDPARTIALSPENDS), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
argsman.AddArg("-changetype", "What type of change to use (\"legacy\", \"p2sh-segwit\", or \"bech32\"). Default is same as -addresstype, except when -addresstype=p2sh-segwit a native segwit output is used when sending to a native segwit address)", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
argsman.AddArg("-consolidatefeerate=<amt>", strprintf("The maximum feerate (in %s/kvB) at which transaction building may use more inputs than strictly necessary so that the wallet's UTXO pool can be reduced (default: %s).", CURRENCY_UNIT, FormatMoney(DEFAULT_CONSOLIDATE_FEERATE)), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
argsman.AddArg("-disablewallet", "Do not load the wallet and disable wallet RPC calls", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
argsman.AddArg("-discardfee=<amt>", strprintf("The fee rate (in %s/kvB) that indicates your tolerance for discarding change by adding it to the fee (default: %s). "
|
||||
"Note: An output is discarded if it is dust at this rate, but we will always discard up to the dust relay fee and a discard fee above that is limited by the fee estimate for the longest target",
|
||||
|
|
|
@ -586,6 +586,9 @@ bool CWallet::CreateTransactionInternal(
|
|||
CoinSelectionParams coin_selection_params; // Parameters for coin selection, init with dummy
|
||||
coin_selection_params.m_avoid_partial_spends = coin_control.m_avoid_partial_spends;
|
||||
|
||||
// Set the long term feerate estimate to the wallet's consolidate feerate
|
||||
coin_selection_params.m_long_term_feerate = m_consolidate_feerate;
|
||||
|
||||
CAmount recipients_sum = 0;
|
||||
const OutputType change_type = TransactionChangeType(coin_control.m_change_type ? *coin_control.m_change_type : m_default_change_type, vecSend);
|
||||
ReserveDestination reservedest(this, change_type);
|
||||
|
@ -659,11 +662,6 @@ bool CWallet::CreateTransactionInternal(
|
|||
return false;
|
||||
}
|
||||
|
||||
// Get long term estimate
|
||||
CCoinControl cc_temp;
|
||||
cc_temp.m_confirm_target = chain().estimateMaxBlocks();
|
||||
coin_selection_params.m_long_term_feerate = GetMinimumFeeRate(*this, cc_temp, nullptr);
|
||||
|
||||
// Calculate the cost of change
|
||||
// Cost of change is the cost of creating the change output + cost of spending the change output in the future.
|
||||
// For creating the change output now, we use the effective feerate.
|
||||
|
|
|
@ -2701,6 +2701,15 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||
walletInstance->m_default_max_tx_fee = max_fee.value();
|
||||
}
|
||||
|
||||
if (gArgs.IsArgSet("-consolidatefeerate")) {
|
||||
if (std::optional<CAmount> consolidate_feerate = ParseMoney(gArgs.GetArg("-consolidatefeerate", ""))) {
|
||||
walletInstance->m_consolidate_feerate = CFeeRate(*consolidate_feerate);
|
||||
} else {
|
||||
error = AmountErrMsg("consolidatefeerate", gArgs.GetArg("-consolidatefeerate", ""));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (chain && chain->relayMinFee().GetFeePerK() > HIGH_TX_FEE_PER_KB) {
|
||||
warnings.push_back(AmountHighWarn("-minrelaytxfee") + Untranslated(" ") +
|
||||
_("The wallet will avoid paying less than the minimum relay fee."));
|
||||
|
|
|
@ -73,6 +73,8 @@ static const CAmount DEFAULT_FALLBACK_FEE = 0;
|
|||
static const CAmount DEFAULT_DISCARD_FEE = 10000;
|
||||
//! -mintxfee default
|
||||
static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
|
||||
//! -consolidatefeerate default
|
||||
static const CAmount DEFAULT_CONSOLIDATE_FEERATE{10000}; // 10 sat/vbyte
|
||||
/**
|
||||
* maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled by default
|
||||
*
|
||||
|
@ -638,6 +640,12 @@ public:
|
|||
* output itself, just drop it to fees. */
|
||||
CFeeRate m_discard_rate{DEFAULT_DISCARD_FEE};
|
||||
|
||||
/** When the actual feerate is less than the consolidate feerate, we will tend to make transactions which
|
||||
* consolidate inputs. When the actual feerate is greater than the consolidate feerate, we will tend to make
|
||||
* transactions which have the lowest fees.
|
||||
*/
|
||||
CFeeRate m_consolidate_feerate{DEFAULT_CONSOLIDATE_FEERATE};
|
||||
|
||||
/** The maximum fee amount we're willing to pay to prioritize partial spend avoidance. */
|
||||
CAmount m_max_aps_fee{DEFAULT_MAX_AVOIDPARTIALSPEND_FEE}; //!< note: this is absolute fee, not fee rate
|
||||
OutputType m_default_address_type{DEFAULT_ADDRESS_TYPE};
|
||||
|
|
Loading…
Add table
Reference in a new issue