-
Notifications
You must be signed in to change notification settings - Fork 38.7k
rpc: Improve documentation and return value of settxfee #18467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice documentation. Not sure on changing the format without an -rpcdeprecated cycle or whether it should be changed at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I agree the documentation is the minimum and it might be good enough. If the change in return the value is too much hassle or if there is not enough interest, I can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't really see the value. Why would an interface return the value you passed in. Should the caller compare the result["feerate"] with the one passed in? Same goes for "active", which is simply the value passed in and cast to a bool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am repeating a pattern I am seeing in setwalletflag and a few other RPCs. I see the value in being explicit what is actually going on, i.e. that setting to 0 means the parameter is not active. Do you have an alternative change you would prefer, for example returning the current fee rate or just the active status? Or would you prefer to not make any change to the return value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current return true unconditionally is completely useless in the same sense. An API client wouldn't know what to do with the value. Should it check if it is false and then throw an error? In that case we might as well throw the error on the server.
So I can see your desire to clean it up, but the cost of breaking every API client for this doesn't seem justified. On top, just because we use that pattern in other calls, doesn't mean that it is a good pattern. I am not really aware of any setter method that returns the set value again, e.g. https://en.cppreference.com/w/cpp/atomic/atomic/store returns void.
I see the value in being explicit what is actually going on
This is what documentation is for, because the RPC interface is mostly used by machines and not humans interpreting the response to get feedback on what was going.
Maybe what could make sense here is to return the fee reason in send* and fund* rpcs. Something like
-> sendtoaddress
<- { "txid" : "deadbeef", "fee_reason" : "paytxfee" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe what could make sense here is to return the fee reason in send* and fund* rpcs. Something like
-> sendtoaddress
<- { "txid" : "deadbeef", "fee_reason" : "paytxfee" }
Nice -- worth proposing as a follow-up.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
|
Added a commit that makes |
|
Concept ACK. Light code review ACK. I guess this breaks the RPC API. Should probably be mentioned in the release notes. |
|
Improving documentation and breaking the API should probably be two pull requests. |
|
Thanks for the feedback! I split documentation and return value changes into separate commits and added release notes. |
|
According to the documentation, breaking changes to the RPC API need to go through an |
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK, good changes. I agree that the API changes need to go through a deprecation process and should be in a separate PR from the non-breaking changes.
|
Added the |
|
ACK bda84a0 (nice documentation) |
|
@MarcoFalke thanks for the feedback. I have removed the two commits related to the RPC return value change since it seems controversial and I agree that the improvement is probably too small to warrant an API change including deprecation cycle. What's left is documentation improvement and that |
|
ACK 3867727, seems useful to error out early instead of later #16257 🕍 Show signature and timestampSignature: Timestamp of file with hash |
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 3867727
| RPCHelpMan{"settxfee", | ||
| "\nSet the transaction fee per kB for this wallet. Overrides the global -paytxfee command line parameter.\n", | ||
| "\nSet the transaction fee per kB for this wallet. Overrides the global -paytxfee command line parameter.\n" | ||
| "Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion if you retouch or for a follow-up:
- "Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.\n",
+ "Can be deactivated by passing 0 as the fee, in which case automatic fee selection will be used by default.\n",
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe what could make sense here is to return the fee reason in send* and fund* rpcs. Something like
-> sendtoaddress
<- { "txid" : "deadbeef", "fee_reason" : "paytxfee" }
Nice -- worth proposing as a follow-up.
|
|
||
| # check that settxfee respects -maxtxfee | ||
| self.restart_node(1, ['-maxtxfee=0.000025'] + self.extra_args[1]) | ||
| assert_raises_rpc_error(-8, "txfee cannot be more than wallet max tx fee", rbf_node.settxfee, Decimal('0.00003')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified this new assertion fails without the changes in rpcwallet.cpp.
meshcollider
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, utACK 3867727
…ettxfee 3867727 rpc: settxfee respects -maxtxfee wallet setting (Fabian Jahr) bda84a0 rpc: Add documentation for deactivating settxfee (Fabian Jahr) Pull request description: ~~Closes 18315~~ `settxfee` can be deactivated by passing 0 as the fee. That does not seem to be documented for the user so this PR adds it in the description. The return value of a simple boolean seems also too simplified given the multiple dimensions that this deactivation feature enables. I.e. it does not seem intuitive if the returned boolean shows that the call succeeded or if means that `settxfee` is active. My suggested solution is to change the return value to a JSON object that included the "active" state and the currently set fee rate. Examples: ``` $ src/bitcoin-cli settxfee 0.0000000 { "active": false, "fee_rate": "0.00000000 BTC/kB" } $ src/bitcoin-cli settxfee 0.0001 { "active": true, "fee_rate": "0.00010000 BTC/kB" } ``` ACKs for top commit: MarcoFalke: ACK 3867727, seems useful to error out early instead of later bitcoin#16257 🕍 jonatack: ACK 3867727 meshcollider: LGTM, utACK 3867727 Tree-SHA512: 642813b5cf6612abb4b6cb63728081a6bd1659d809e0149c8f56060b6da7253fee989b3b202854f3051df3773c966799af30b612648c466b099f00590f356548
…etting Summary: PR description: > settxfee can be deactivated by passing 0 as the fee. That does not seem to be documented for the user so this PR adds it in the description. > Added a commit that makes settxfee respect the setting -maxtxfee This is a backport of Core [[bitcoin/bitcoin#18467 | PR18467]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D8939
Closes 18315settxfeecan be deactivated by passing 0 as the fee. That does not seem to be documented for the user so this PR adds it in the description. The return value of a simple boolean seems also too simplified given the multiple dimensions that this deactivation feature enables. I.e. it does not seem intuitive if the returned boolean shows that the call succeeded or if means thatsettxfeeis active. My suggested solution is to change the return value to a JSON object that included the "active" state and the currently set fee rate.Examples: