Skip to content

Conversation

@fjahr
Copy link
Contributor

@fjahr fjahr commented Mar 29, 2020

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"
}

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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" }

Copy link
Member

@jonatack jonatack Apr 14, 2020

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.

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 30, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@fjahr
Copy link
Contributor Author

fjahr commented Mar 30, 2020

Added a commit that makes settxfee respect the setting -maxtxfee as suggested by @MarcoFalke here: #18315 (comment)

@jonasschnelli
Copy link
Contributor

Concept ACK. Light code review ACK.

I guess this breaks the RPC API. Should probably be mentioned in the release notes.

@maflcko
Copy link
Member

maflcko commented Mar 31, 2020

Improving documentation and breaking the API should probably be two pull requests.

@fjahr
Copy link
Contributor Author

fjahr commented Mar 31, 2020

Thanks for the feedback! I split documentation and return value changes into separate commits and added release notes.

@maflcko
Copy link
Member

maflcko commented Mar 31, 2020

According to the documentation, breaking changes to the RPC API need to go through an -rpcdeprecated cycle. See https://github.com/bitcoin/bitcoin/blob/master/doc/JSON-RPC-interface.md#versioning

Copy link
Member

@jonatack jonatack left a 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.

@fjahr
Copy link
Contributor Author

fjahr commented Apr 2, 2020

Added the -deprecatedrpc=settxfee option and mentioned it in the release notes.

@maflcko
Copy link
Member

maflcko commented Apr 10, 2020

ACK bda84a0 (nice documentation)
ACK 6c1502768e72ec883a8a5d1682e335f62c8109aa (with previous commit removed, nice behaviour change to avoid setting an invalid value)
Not sure about the other commits in this pull

@fjahr
Copy link
Contributor Author

fjahr commented Apr 14, 2020

@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 settxfee respects -maxtxfee now. I am not if this should close #18315 now and will leave it to the user who reported it.

@maflcko
Copy link
Member

maflcko commented Apr 14, 2020

ACK 3867727, seems useful to error out early instead of later #16257 🕍

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

ACK 38677274f931088218eeb1f258077d3387f39c89, seems useful to error out early instead of later #16257 🕍
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjbvQv+KyR+wShkBxepoe9CU1bQbiVoMueRyAj4uWHzXigU/QJTSVAR1dr3noU7
TuhnX1w90qUGOoaB22wKCikR3Hi+EaBpLBGnEpEz3a57jKoKLZVSFAF3Q0xQNP9l
suQFyCz+GVc54quhKau1ph/Gj2HhuqJ+Cpx4RClxlVzGQ06WaQAx9qBmUa5Jympp
vh558dTtMEG2cc0FtB57VCHyokHoPX4KolK83UkHISI58lhCXWtNmUmy2QBWS0GX
HPcXIF7v/YfZsLWmy1KgVZ9g+OWQL88MTdOhojWlNjE/4U5WsU0Fs4QntehVOmbU
SJXPerhtWQT2nvd/j2HlA/fpErDHLBgAhhKM+VyblHUV2iKLEeZ7YXf4x9CAFzlK
ue+1jv02oRrAhos0tEctoBSgRO6cxQwyuoYlC3ckQIxqjA6XIDsgspmMvQAu9Hif
RD38lItiNJ0XaOsV0wjsBN+zDBuxaPCCA7OHsOLLNMMW4iI4p13hk0pfiZ235ILG
vyNUt60K
=l0vw
-----END PGP SIGNATURE-----

Timestamp of file with hash 262b14486a279571b51bb4e1b641d530dfa6be4293fff0bb9eb0be1f38a9424b -

Copy link
Member

@jonatack jonatack left a 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",
Copy link
Member

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",

Copy link
Member

@jonatack jonatack Apr 14, 2020

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'))
Copy link
Member

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.

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, utACK 3867727

@maflcko maflcko merged commit c2e53ff into bitcoin:master Apr 17, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 17, 2020
…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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 18, 2021
…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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants