rpc: bumpfee, improve doc for ‘reduce_output’ arg #28505

pull furszy wants to merge 1 commits into bitcoin:master from furszy:2023_rpc_improve_reduce_output_description changing 5 files +34 −30
  1. furszy commented at 11:11 am on September 19, 2023: member

    Fixes #28180. Resulted from discussions with S3RK, achow101, and Murch.

    The current argument name and description are dangerous as it don’t describe the case where the user selects the recipient output as the change address. This one could end up been increased by the inputs minus outputs remainder. Which, when bumpfee adds new inputs to the transaction, leads the process to send more coins to the recipient. Which is not what the user would expect from a ‘reduce_output’ param naming.

  2. DrahtBot commented at 11:11 am on September 19, 2023: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK murchandamus, S3RK, achow101
    Concept ACK ismaelsadeeq

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label RPC/REST/ZMQ on Sep 19, 2023
  4. DrahtBot added the label CI failed on Sep 19, 2023
  5. furszy force-pushed on Sep 19, 2023
  6. furszy force-pushed on Sep 19, 2023
  7. DrahtBot removed the label CI failed on Sep 19, 2023
  8. DrahtBot added the label Needs rebase on Sep 19, 2023
  9. in src/wallet/rpc/spend.cpp:1022 in 4dbc595d9b outdated
    1016@@ -1017,10 +1017,10 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
    1017                     {"outputs", RPCArg::Type::ARR, RPCArg::Default{UniValue::VARR}, "The outputs specified as key-value pairs.\n"
    1018                              "Each key may only appear once, i.e. there can only be one 'data' output, and no address may be duplicated.\n"
    1019                              "At least one output of either type must be specified.\n"
    1020-                             "Cannot be provided if 'reduce_output' is specified.",
    1021+                             "Cannot be provided if 'change_output_index' is specified.",
    1022                         OutputsDoc(),
    1023                         RPCArgOptions{.skip_type_check = true}},
    1024-                    {"reduce_output", RPCArg::Type::NUM, RPCArg::DefaultHint{"not set, detect change automatically"}, "The 0-based index of the output from which the additional fees will be deducted. In general, this should be the position of change output. Cannot be provided if 'outputs' is specified."},
    1025+                    {"change_output_index", RPCArg::Type::NUM, RPCArg::DefaultHint{"not set, detect change automatically"}, "The change of the bumped transaction will be sent to the output script specified by this 0-based index parameter. The to-be-replaced transaction output pointed by this parameter could either be increased or decreased depending on the inputs minus outputs remainder. Cannot be provided if 'outputs' is specified."},
    


    jonatack commented at 6:34 pm on September 19, 2023:
    Note that changing the name of this RPC option merged two months ago in #26467 would need to make the upcoming release (in order not to break software that consumes RPCs bumpfee and psbtbumpfee).

    furszy commented at 9:27 am on September 20, 2023:
    yes. The goal of the PR is to not release #26467 as is. Because it is dangerous for the user (reason #26467 (review)).
  10. in test/functional/wallet_bumpfee.py:285 in 4dbc595d9b outdated
    282@@ -283,10 +283,10 @@ def test_single_output(self):
    283         tx = wallet.sendall(recipients=[wallet.getnewaddress()], fee_rate=2, options={"inputs": [utxos[0]]})
    284 
    285         # Reduce the only output with a crazy high feerate, should fail as the output would be dust
    


    kevkevinpal commented at 3:02 am on September 21, 2023:
    We might want to change this comment to “Change the output index to the only output with a crazy high feerate, should fail as the output would be dust”

    furszy commented at 9:14 am on September 21, 2023:
    done, thx
  11. in test/functional/wallet_bumpfee.py:288 in 4dbc595d9b outdated
    282@@ -283,10 +283,10 @@ def test_single_output(self):
    283         tx = wallet.sendall(recipients=[wallet.getnewaddress()], fee_rate=2, options={"inputs": [utxos[0]]})
    284 
    285         # Reduce the only output with a crazy high feerate, should fail as the output would be dust
    286-        assert_raises_rpc_error(-4, "The transaction amount is too small to pay the fee", wallet.bumpfee, txid=tx["txid"], options={"fee_rate": 1100, "reduce_output": 0})
    287+        assert_raises_rpc_error(-4, "The transaction amount is too small to pay the fee", wallet.bumpfee, txid=tx["txid"], options={"fee_rate": 1100, "change_output_index": 0})
    288 
    289         # Reduce the only output successfully
    


    kevkevinpal commented at 3:03 am on September 21, 2023:
    We might want to change this comment to “Change the output index successfully”

    furszy commented at 9:14 am on September 21, 2023:
    done, thx
  12. in src/wallet/feebumper.cpp:167 in 4dbc595d9b outdated
    161@@ -162,10 +162,10 @@ bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid)
    162 }
    163 
    164 Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCoinControl& coin_control, std::vector<bilingual_str>& errors,
    165-                                 CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx, bool require_mine, const std::vector<CTxOut>& outputs, std::optional<uint32_t> reduce_output)
    166+                                 CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx, bool require_mine, const std::vector<CTxOut>& outputs, std::optional<uint32_t> change_output_index)
    167 {
    168     // Cannot both specify new outputs and an output to reduce
    


    kevkevinpal commented at 3:07 am on September 21, 2023:
    Might want to change to “Cannot both specify new outputs and an output to change”

    furszy commented at 9:13 am on September 21, 2023:
    done, thx
  13. furszy force-pushed on Sep 21, 2023
  14. achow101 added this to the milestone 26.0 on Sep 21, 2023
  15. furszy force-pushed on Sep 21, 2023
  16. DrahtBot removed the label Needs rebase on Sep 21, 2023
  17. S3RK commented at 9:20 am on September 23, 2023: contributor

    Approach ACK

    Explicitly specifying change output for bumpfee and reducing an arbitrary output is two different features. #26467 originally was developed to specify the change output, hence updating documentation is the correct way to fix #28180 for 26.0

    We can discuss whether we want to support deducting fees from an arbitrary output in a separate issue.

  18. achow101 requested review from murchandamus on Sep 23, 2023
  19. achow101 requested review from achow101 on Sep 23, 2023
  20. in src/rpc/client.cpp:266 in 3f2f927c7e outdated
    262@@ -263,13 +263,13 @@ static const CRPCConvertParam vRPCConvertParams[] =
    263     { "bumpfee", 1, "fee_rate"},
    264     { "bumpfee", 1, "replaceable"},
    265     { "bumpfee", 1, "outputs"},
    266-    { "bumpfee", 1, "reduce_output"},
    267+    { "bumpfee", 1, "change_output_index"},
    


    murchandamus commented at 9:23 pm on September 26, 2023:
    I just wanted to point out that I first read “change” as a verb, and I was wondering what “changing an output index” might do. Something like original_change_index might be more self-explanatory.

    furszy commented at 11:21 pm on September 26, 2023:
    sounds good.
  21. in src/wallet/rpc/spend.cpp:1022 in 3f2f927c7e outdated
    1015@@ -1016,10 +1016,10 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
    1016                     {"outputs", RPCArg::Type::ARR, RPCArg::Default{UniValue::VARR}, "The outputs specified as key-value pairs.\n"
    1017                              "Each key may only appear once, i.e. there can only be one 'data' output, and no address may be duplicated.\n"
    1018                              "At least one output of either type must be specified.\n"
    1019-                             "Cannot be provided if 'reduce_output' is specified.",
    1020+                             "Cannot be provided if 'change_output_index' is specified.",
    1021                         OutputsDoc(),
    1022                         RPCArgOptions{.skip_type_check = true}},
    1023-                    {"reduce_output", RPCArg::Type::NUM, RPCArg::DefaultHint{"not set, detect change automatically"}, "The 0-based index of the output from which the additional fees will be deducted. In general, this should be the position of change output. Cannot be provided if 'outputs' is specified."},
    1024+                    {"change_output_index", RPCArg::Type::NUM, RPCArg::DefaultHint{"not set, detect change automatically"}, "The change of the bumped transaction will be sent to the output script specified by this 0-based index parameter. The to-be-replaced transaction output pointed by this parameter could either be increased or decreased depending on the inputs minus outputs remainder. Cannot be provided if 'outputs' is specified."},
    


    murchandamus commented at 9:28 pm on September 26, 2023:

    How about:

    0                    {"change_output_index", RPCArg::Type::NUM, RPCArg::DefaultHint{"not set, detect change automatically"}, "The 0-based index of the change output on the original transaction. The indicated output will be recycled into the new change output on the bumped transaction. The remainder after paying the recipients and fees will be sent to the output script of the original change output. The change output’s amount can increase if bumping the transaction adds new inputs, otherwise it will decrease. Cannot be used in combination with the 'outputs' option."},
    

    furszy commented at 11:21 pm on September 26, 2023:
    sure, done.
  22. in src/wallet/feebumper.cpp:169 in 3f2f927c7e outdated
    168-    // Cannot both specify new outputs and an output to reduce
    169-    if (!outputs.empty() && reduce_output.has_value()) {
    170-        errors.push_back(Untranslated("Cannot specify both new outputs to use and an output index to reduce"));
    171+    // For now, cannot specify both new outputs to use and an output index to send change
    172+    if (!outputs.empty() && change_output_index.has_value()) {
    173+        errors.push_back(Untranslated("Cannot specify both new outputs to use and an output index to send change"));
    


    murchandamus commented at 10:09 pm on September 26, 2023:
    0        errors.push_back(Untranslated("The options 'outputs' and 'change_output_index' are incompatible. You can only either specify a new set of outputs, or designate a change output to be recycled."));
    

    furszy commented at 11:21 pm on September 26, 2023:
    done
  23. murchandamus commented at 10:16 pm on September 26, 2023: contributor
    Approach ACK, I do have a few suggestions on the documentation and naming of things, though.
  24. rpc: bumpfee, improve doc for 'reduce_output' arg
    The current argument name and description are dangerous as it don't
    describe the case where the user selects the recipient output as the
    change address. This one could end up been increased by the inputs
    minus outputs remainder. Which, when bumpfee adds new inputs
    to the transaction, leads the process to send more coins to the
    recipient. Which is not what the user would expect from a
    'reduce_output' param naming.
    
    Co-authored-by: Murch <murch@murch.one>
    b3db8c9d5c
  25. furszy force-pushed on Sep 26, 2023
  26. DrahtBot added the label CI failed on Sep 27, 2023
  27. ismaelsadeeq commented at 10:37 am on September 27, 2023: member
    Concept ACK
  28. murchandamus approved
  29. murchandamus commented at 5:27 pm on September 27, 2023: contributor
    ACK b3db8c9d5ccfe5c31341169fa7ac044427122921
  30. S3RK commented at 7:58 pm on September 27, 2023: contributor

    ACK b3db8c9d5ccfe5c31341169fa7ac044427122921

    Maybe add a test case where bumping leads to new input and increased change output?

  31. achow101 commented at 8:35 pm on September 27, 2023: member
    ACK b3db8c9d5ccfe5c31341169fa7ac044427122921
  32. DrahtBot removed review request from achow101 on Sep 27, 2023
  33. achow101 merged this on Sep 27, 2023
  34. achow101 closed this on Sep 27, 2023

  35. luke-jr commented at 9:51 pm on October 2, 2023: member
    The bug here is the behaviour, not the documentation! It shouldn’t do that!
  36. achow101 commented at 10:22 pm on October 2, 2023: member

    The bug here is the behaviour, not the documentation! It shouldn’t do that!

    Changing the documentation to reflect the current behavior does not preclude reintroducing reduce_output in the future that has the correct behavior. The discussion at CoreDev concluded that both an option to indicate which output is change and an option to indicate which output the fee should be taken from are reasonable things that a user may wish to do. As the former is what was implemented, the documentation should reflect that.

  37. Frank-GER referenced this in commit 521291b6da on Oct 5, 2023
  38. furszy deleted the branch on Jan 16, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-06-29 07:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me