-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Description
The -maxtxfee
(which is put into m_default_max_tx_fee
) is documented as "the maximum total fees to use in a single wallet transaction"
Line 63 in 632a2bb
argsman.AddArg("-maxtxfee=<amt>", strprintf("Maximum total fees (in %s) to use in a single wallet transaction; setting this too low may abort large transactions (default: %s)", |
This seems true in many instances when we look at the code:
Lines 1293 to 1295 in 632a2bb
if (current_fee > wallet.m_default_max_tx_fee) { | |
return util::Error{TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED)}; | |
} |
bitcoin/src/wallet/feebumper.cpp
Lines 114 to 119 in 632a2bb
const CAmount max_tx_fee = wallet.m_default_max_tx_fee; | |
if (new_total_fee > max_tx_fee) { | |
errors.push_back(strprintf(Untranslated("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)"), | |
FormatMoney(new_total_fee), FormatMoney(max_tx_fee))); | |
return feebumper::Result::WALLET_ERROR; | |
} |
bitcoin/src/node/transaction.cpp
Lines 71 to 79 in 632a2bb
if (max_tx_fee > 0) { | |
// First, call ATMP with test_accept and check the fee. If ATMP | |
// fails here, return error immediately. | |
const MempoolAcceptResult result = node.chainman->ProcessTransaction(tx, /*test_accept=*/ true); | |
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) { | |
return HandleATMPError(result.m_state, err_string); | |
} else if (result.m_base_fees.value() > max_tx_fee) { | |
return TransactionError::MAX_FEE_EXCEEDED; | |
} |
But there are also places where this value is used as a feerate per KvB:
Lines 3061 to 3064 in 632a2bb
if (chain && CFeeRate{max_fee.value(), 1000} < chain->relayMinFee()) { | |
error = strprintf(_("Invalid amount for %s=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"), | |
"-maxtxfee", args.GetArg("-maxtxfee", ""), chain->relayMinFee().ToString()); | |
return nullptr; |
bitcoin/src/wallet/rpc/spend.cpp
Line 433 in 632a2bb
CFeeRate max_tx_fee_rate(pwallet->m_default_max_tx_fee, 1000); |
I don't think these instances of conversions to feerate result in anything very problematic, but it doesn't make sense to just convert this fee to a feerate because not every tx is the same size. I can see why a wallet user might want a maximum fee and maximum feerate. So my suggested solution is to have both: add a -maxfeerate
and put those checks under the new value.