Wallet: Add maxfeerate wallet startup option#29278
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/29278. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible places where named args for integral literals may be used (e.g.
2026-07-03 16:37:49 |
maxfeerate and maxburnamount startup option and use maxfeerate to check max wallet tx feeratemaxfeerate and maxburnamount startup option
glozow
left a comment
There was a problem hiding this comment.
I mentioned adding a maxfeerate option in #29220, but I was more imagining it as a wallet-only option. I don't think that wallet configurations should bleed into how the node RPCs function. Instead, the interaction there should be for wallet to pass it as a param to BroadcastTransaction when the it submits a tx to the node.
I'm also not sure about maxburnamount being a node-wide config (#29217 (comment))
|
Thanks @glozow for your review. |
|
I agree this feels more like it should be a wallet option. |
b9f2ddc to
0c9e0c5
Compare
|
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
maxfeerate and maxburnamount startup optionmaxfeerate wallet startup option
maxfeerate wallet startup optionmaxfeerate wallet startup option
|
Forced pushed from 2576efc to 0c9e0c5 Compare the diff
|
josibake
left a comment
There was a problem hiding this comment.
It seems odd to me that we would ever have maxtxfee and maxfeerate set together as they seem to cover entirely different scenarios.
For maxtxfee, a user is expressing "I don't or care what my transaction size is but I know I never want to spend more than X in total fees."
For maxfeerate as user is expressing "I know that my transactions will vary a lot in size, so I don't know what the total fees will be, but I do know that I don't want to pay more than X sats/per vbyte."
I am struggling to think of a scenario where it makes sense to combine them. On the other hand, if I set a maxtxfee of Y and a maxfeerate of X, there input sets that are valid for Y but not valid for X and also inputs that are valid for X but not for Y.
What do you think about only letting the user set one or the other? Or is there a use case for caring about the total fees you pay AND caring about the sats per vbyte you pay that I'm not understanding?
I think it makes sense to have both. I could have a |
But in this example, if you typo'd a feerate orders of magnitude higher, your Seems less footgunny to only let the user set one or the other (and then as a belt and suspenders still check the defaults for both, regardless of what is set?). But I might be overthinking this.. just seems really gross to have to now consider both of these in coin selection, especially if a user sets wonky values. |
|
Thank you for your comments @josibake @glozow @achow101 , will address review comments shortly.
I don't think this is true; it depends on what your This is not likely to occur. I did a manual test on master. When I set However, in some cases where you set a low On this branch, if I set my IIUC Maybe I should differentiate between the two error messages and make it more verbose, so that users can know which one is hit and adjust if its not intentional. |
|
Rebased to fix merge conflict. C.I failure in https://github.com/bitcoin/bitcoin/actions/runs/26634202425/job/78492906366?pr=29278 is unrelated. |
polespinasa
left a comment
There was a problem hiding this comment.
Approach ACK
Left some comments.
The PR is already well worked and reviewed so I mostly have nits before acking it.
Note that after #32138 this line of the PR description is outdated. |
-BEGIN VERIFY SCRIPT- git grep -l "m_default_max_tx_fee" src | xargs sed -i "s/m_default_max_tx_fee/m_max_tx_fee/g" git grep -l "getDefaultMaxTxFee" src | xargs sed -i "s/getDefaultMaxTxFee/getMaxTxFee/g" -END VERIFY SCRIPT- - The value is not always the default but can be configured during startup so `m_max_tx_fee` is the right name not `m_default_max_tx_fee`.
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
- Also update `-maxapsfee` option from `max_fee` to `max_aps_fee`. This fixes the ambiguity in the variable name.
| return Untranslated("Fee exceeds maximum configured by user (maxtxfee)"); | ||
| case TransactionError::MAX_FEE_RATE_EXCEEDED: | ||
| return Untranslated("Fee rate exceeds maximum configured by user (maxfeerate)"); |
There was a problem hiding this comment.
in 2baa98f [util]: add a new transaction error type
Missing - before maxtxfee and maxfeerate
- The commits adds a new wallet startup option `-maxfeerate` - The value will be used as the upper limit of wallet transaction fee rate. - The commit updates all instances where `-maxtxfee` value is utilized to check wallet transactions fee rate upper limit to now use `-maxfeerate` value.
`BroadcastTransaction` now accepts a fee rate limit as an additional input parameter. It rejects transactions whose fee exceeds the maximum fee amount permitted by that fee rate for the transaction vsize. Compare against `maxfeerate.GetFee(vsize)` instead of reconstructing a fee rate from the accepted fee. This preserves the existing rounded fee cap semantics used by `testmempoolaccept` and avoids rejecting transactions whose rounded fee is still within the configured limit. This allows callers to distinguish between failures caused by the absolute fee limit (`-maxtxfee`) and the fee rate limit (`maxfeerate` or `-maxfeerate`). `TestSimpleSpend` creates transactions paying `DEFAULT_TRANSACTION_MAXFEE`. Since `BroadcastTransaction` now also checks the fee rate limit, these small high-fee transactions would exceed `DEFAULT_MAX_TRANSACTION_FEERATE`. Update the test broadcast limit to be slightly above the transaction fee rate. In `wallet_fundrawtransaction.py`'s `test_22670` subtest, restart node 0 with `-maxfeerate` above `-minrelaytxfee` so high-feerate transactions can be broadcast.
- This distinguishes maxfeerate and maxtxfee error messages.
This commit prevents the wallet from submitting or broadcasting transactions above `-maxfeerate`, and tests the new functionality. Compare wallet transaction fees against `maxfeerate.GetFee(vsize)` instead of reconstructing a fee rate from the rounded fee. This allows transactions whose requested fee rate is at the configured limit, even when the resulting fee is rounded up to whole satoshis. `rpc_psbt.py` functional test nodes are modified to start with a custom `-maxfeerate=1`, because the test requires creating and broadcasting a transaction with a high fee rate. A node in some subtests in `wallet_fundrawtransaction.py` is restarted with `-maxfeerate=1` because those subtests require the node's wallet to be able to create and broadcast transactions with a high fee rate.
- Wallets cannot create transactions with fee rates below `-minrelaytxfee`, and they also reject transactions whose total fee exceeds `-maxtxfee`. - Warn when a 1 kvB transaction paying exactly `-maxtxfee` would still have a fee rate below `-minrelaytxfee`. In this configuration, some transactions that meet the minimum relay fee rate may exceed `-maxtxfee`, preventing the wallet from creating them. - Keep this warning independent from the existing high `-maxtxfee` warning, so users see both warnings when both conditions apply.
|
Forced pushed from 6f05410 to d46adaa 6f05410...d46adaa
|
This PR fixes #29220
The PR adds a wallet
-maxfeeratestartup option, as the upper limit of wallet transactions fee rate.This fixes the ambiguity of using
maxtxfeevalue to check the upper limit of transactions fee rate.Wallet will not create a transaction with fee rate above
maxfeeratevalue.This PR adds a functional test that ensure the behavior is enforced.