Use wallet RBF default for walletcreatefundedpsbt #15911

pull Sjors wants to merge 3 commits into bitcoin:master from Sjors:2019/04/walletcreatefundedpsbt changing 5 files +47 −23
  1. Sjors commented at 6:05 pm on April 27, 2019: member

    The walletcreatefundedpsbt RPC call currently ignores -walletrbf and defaults to not use RBF. This PR fixes that.

    This PR also replaces UniValue in ConstructTransaction with a bool in preparation of moving this helper method out of the RPC codebase entirely. This may be a bit overkill, but does slightly simplify it.

    Fixes #15878

  2. Sjors commented at 6:16 pm on April 27, 2019: member
    (my initial attempt ddfce96d79809112d8253a8a82cc9bf11c3a1beb used Optional<Bool>) Given that wallet->m_signal_rbf is a boolean I think we should just stop treating replaceable as an optional parameter. In that case ConstructTransaction can take a boolean parameter and be simplified a bit.
  3. Sjors force-pushed on Apr 27, 2019
  4. DrahtBot commented at 8:55 pm on April 27, 2019: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #16378 ([WIP] The ultimate send RPC by Sjors)
    • #16377 ([rpc] don’t automatically append inputs in walletcreatefundedpsbt & fundrawtransaction by Sjors)
    • #14641 (rpc: Add min_conf option to fund transaction calls by promag)
    • #11413 ([wallet] [rpc] sendtoaddress/sendmany: Add explicit feerate option by kallewoof)

    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.

  5. fanquake added the label RPC/REST/ZMQ on Apr 27, 2019
  6. in src/wallet/rpcwallet.cpp:3982 in 609685107b outdated
    3978@@ -3979,7 +3979,7 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
    3979                                     {"vout_index", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "The zero-based output index, before a change output is added."},
    3980                                 },
    3981                             },
    3982-                            {"replaceable", RPCArg::Type::BOOL, /* default */ "false", "Marks this transaction as BIP125 replaceable.\n"
    3983+                            {"replaceable", RPCArg::Type::BOOL, /* default */ "fallback to wallet's default", "Marks this transaction as BIP125 replaceable.\n"
    


    luke-jr commented at 6:38 am on May 1, 2019:
    “fallback to” seems unnecessary here.

    MarcoFalke commented at 1:36 pm on May 1, 2019:

    Would need a scripted diff to change that?

    0$ git grep --count  "fallback to wallet's default" 
    1src/wallet/rpcwallet.cpp:7
    

    Sjors commented at 3:42 pm on May 1, 2019:
    I used the same wording as elsewhere, so could indeed do a replace-all.

    Sjors commented at 1:50 pm on May 12, 2019:
    Done, but not scripted.
  7. in src/wallet/rpcwallet.cpp:4020 in 609685107b outdated
    4013@@ -4014,7 +4014,11 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
    4014 
    4015     CAmount fee;
    4016     int change_position;
    4017-    CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], request.params[3]["replaceable"]);
    4018+    bool rbf = pwallet->m_signal_rbf;
    4019+    if (!request.params[3]["replaceable"].isNull()) {
    4020+        rbf = request.params[3]["replaceable"].isTrue();
    


    luke-jr commented at 6:38 am on May 1, 2019:
    Probably ought to throw an error if it’s not a boolean here.

    Sjors commented at 1:50 pm on May 12, 2019:
    Added a check.
  8. luke-jr changes_requested
  9. luke-jr referenced this in commit fb40737d77 on May 1, 2019
  10. Sjors force-pushed on May 12, 2019
  11. Sjors force-pushed on May 12, 2019
  12. MarcoFalke added the label Needs backport on May 16, 2019
  13. MarcoFalke added this to the milestone 0.18.1 on May 16, 2019
  14. MarcoFalke commented at 7:34 pm on May 23, 2019: member
    utACK 9b1b9cf5632be18f3ad1bf2e10ebd004fceb2368
  15. MarcoFalke commented at 4:59 pm on May 25, 2019: member

    @Sjors Please squash the first and third commit, as they don’t compile:

     0  CXX      wallet/libbitcoin_wallet_a-rpcwallet.o
     1wallet/rpcwallet.cpp: In function UniValue walletcreatefundedpsbt(const JSONRPCRequest&):
     2wallet/rpcwallet.cpp:4137:143: error: cannot convert const UniValue to bool
     3 4137 |     CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], request.params[3]["replaceable"]);
     4      |                                                                                                                                               ^
     5      |                                                                                                                                               |
     6      |                                                                                                                                               const UniValue
     7In file included from wallet/rpcwallet.cpp:20:
     8./rpc/rawtransaction_util.h:30:128: note:   initializing argument 4 of CMutableTransaction ConstructTransaction(const UniValue&, const UniValue&, const UniValue&, bool)
     9   30 | CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, bool rbf);
    10      |                                                                                                                           ~~~~~^~~
    
  16. MarcoFalke added the label Wallet on Jun 21, 2019
  17. MarcoFalke added the label Waiting for author on Jun 21, 2019
  18. MarcoFalke commented at 12:20 pm on June 21, 2019: member
    @Sjors ^ :eyes:
  19. Sjors commented at 2:28 pm on June 21, 2019: member
    Soon (TM), sorry for the delay.
  20. CLEANSKY97 approved
  21. Sjors force-pushed on Jun 26, 2019
  22. Sjors commented at 0:34 am on June 26, 2019: member
    Rebased and squashed first and last commit. @MarcoFalke hopefully good to go.
  23. meshcollider removed the label Waiting for author on Jun 26, 2019
  24. in test/functional/rpc_psbt.py:212 in e8a914c225 outdated
    211             assert "bip32_derivs" not in psbt_in
    212         assert_equal(decoded_psbt["tx"]["locktime"], block_height+2)
    213 
    214-        # Same construction with only locktime set
    215-        psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}], block_height, {}, True)
    216+        # Same construction with only locktime set and RBF explictly enabled
    


    meshcollider commented at 10:57 am on June 26, 2019:
    nit: typo in explictly
  25. meshcollider commented at 11:00 am on June 26, 2019: contributor
    Code review ACK f847fa961c29cf95416ba489d46d2a61368c7c61
  26. Sjors force-pushed on Jun 26, 2019
  27. Sjors commented at 8:07 pm on June 26, 2019: member

    Fixed the typo. You can see the diff with:

    0PREV=f847fa9 N=2 && git range-diff `git merge-base --all HEAD $PREV`...$PREV HEAD~$N...HEAD
    
  28. in src/rpc/rawtransaction_util.cpp:22 in 07299aa229 outdated
    17@@ -18,7 +18,7 @@
    18 #include <util/rbf.h>
    19 #include <util/strencodings.h>
    20 
    21-CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, const UniValue& rbf)
    22+CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, bool rbf)
    


    l2a5b1 commented at 8:06 pm on July 10, 2019:

    Will ConstructTransaction be moved out of the RPC module?

    Without this change the issue could probably have been addressed with a small update in walletcreatefundedpsbt.

    If ConstructTransaction stays in the RPC codebase forever then this change has also introduced duplicate code at two call sites for no reason.


    Sjors commented at 9:14 am on July 11, 2019:
    I expect more stuff to be moved out of the RPC over time, but for now this was the simplest fix, also easiest to backport.
  29. in test/functional/rpc_psbt.py:229 in 07299aa229 outdated
    224 
    225         # Same construction without optional arguments
    226         psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}])
    227         decoded_psbt = self.nodes[0].decodepsbt(psbtx_info["psbt"])
    228         for tx_in in decoded_psbt["tx"]["vin"]:
    229-            assert tx_in["sequence"] > MAX_BIP125_RBF_SEQUENCE
    


    l2a5b1 commented at 8:06 pm on July 10, 2019:
    Perhaps test the walletrbf=0 case assert tx_in["sequence"] > MAX_BIP125_RBF_SEQUENCE on nodes[1]?

    Sjors commented at 9:38 am on July 11, 2019:
    Added a commit with that test (it shouldn’t break existing ACKs)
  30. l2a5b1 commented at 8:20 pm on July 10, 2019: contributor

    ACK 4348388

    +1 for finding this issue and fixing it. Feel free to ignore my review comments.

  31. in test/functional/rpc_psbt.py:231 in 17f0cb0f79 outdated
    232 
    233+        # Same construction without optional arguments, for a node with -walletrbf=0
    234+        unspent1 = self.nodes[1].listunspent()[0]
    235+        psbtx_info = self.nodes[1].walletcreatefundedpsbt([{"txid":unspent1["txid"], "vout":unspent1["vout"]}], [{self.nodes[2].getnewaddress():unspent1["amount"]+1}], block_height)
    236+        decoded_psbt = self.nodes[1].decodepsbt(psbtx_info["psbt"])
    237+        for tx_in, psbt_in in zip(decoded_psbt["tx"]["vin"], decoded_psbt["inputs"]):
    


    l2a5b1 commented at 1:40 pm on July 11, 2019:

    No need to zip here.

    0for tx_in in decoded_psbt["tx"]["vin"]:
    1    assert tx_in["sequence"] > MAX_BIP125_RBF_SEQUENCE
    

    promag commented at 10:58 pm on July 14, 2019:

    17f0cb0f792883c791954472a3173bf46356ce09

    Agree, same as L223 is enough.

  32. in test/functional/rpc_psbt.py:232 in 17f0cb0f79 outdated
    223@@ -224,6 +224,13 @@ def run_test(self):
    224             assert_equal(tx_in["sequence"], MAX_BIP125_RBF_SEQUENCE)
    225         assert_equal(decoded_psbt["tx"]["locktime"], 0)
    226 
    227+        # Same construction without optional arguments, for a node with -walletrbf=0
    228+        unspent1 = self.nodes[1].listunspent()[0]
    229+        psbtx_info = self.nodes[1].walletcreatefundedpsbt([{"txid":unspent1["txid"], "vout":unspent1["vout"]}], [{self.nodes[2].getnewaddress():unspent1["amount"]+1}], block_height)
    230+        decoded_psbt = self.nodes[1].decodepsbt(psbtx_info["psbt"])
    231+        for tx_in, psbt_in in zip(decoded_psbt["tx"]["vin"], decoded_psbt["inputs"]):
    232+            assert tx_in["sequence"] > MAX_BIP125_RBF_SEQUENCE
    


    promag commented at 10:58 pm on July 14, 2019:

    17f0cb0f792883c791954472a3173bf46356ce09

    Use assert_greater_than.

  33. in test/functional/rpc_psbt.py:208 in 43483889cf outdated
    201@@ -197,26 +202,26 @@ def run_test(self):
    202         # replaceable arg
    203         block_height = self.nodes[0].getblockcount()
    204         unspent = self.nodes[0].listunspent()[0]
    205-        psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}], block_height+2, {"replaceable":True}, False)
    206+        psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}], block_height+2, {"replaceable": False}, False)
    207         decoded_psbt = self.nodes[0].decodepsbt(psbtx_info["psbt"])
    208         for tx_in, psbt_in in zip(decoded_psbt["tx"]["vin"], decoded_psbt["inputs"]):
    209-            assert_equal(tx_in["sequence"], MAX_BIP125_RBF_SEQUENCE)
    210+            assert tx_in["sequence"] > MAX_BIP125_RBF_SEQUENCE
    


    promag commented at 11:00 pm on July 14, 2019:

    43483889cfa7cb0aa95ba6bb298c9d644e4f21d0

    Use assert_greater_than.

  34. promag commented at 11:02 pm on July 14, 2019: member
    Concept ACK.
  35. MarcoFalke removed this from the milestone 0.18.1 on Jul 18, 2019
  36. MarcoFalke added this to the milestone 0.18.2 on Jul 18, 2019
  37. MarcoFalke commented at 7:34 pm on July 18, 2019: member
    Moved to 0.18.2
  38. fanquake added the label Waiting for author on Jul 25, 2019
  39. DrahtBot added the label Needs rebase on Jul 27, 2019
  40. [rpc] walletcreatefundedpsbt: use wallet default RBF 4fcb698bc2
  41. [doc] rpc: remove "fallback to" from RBF default help 9ed062b568
  42. [test] walletcreatefundedpsbt: check RBF is disabled when -walletrbf=0 d6b3640ac7
  43. Sjors force-pushed on Jul 27, 2019
  44. Sjors commented at 5:40 pm on July 27, 2019: member
    Rebased and addressed nits.
  45. DrahtBot removed the label Needs rebase on Jul 27, 2019
  46. achow101 commented at 8:35 pm on July 30, 2019: member
    Code Review ACK d6b3640ac732f6f66a8cb6761084d1beecc8a876
  47. Sjors commented at 4:30 pm on August 1, 2019: member
  48. l2a5b1 commented at 11:49 am on August 2, 2019: contributor
    re-ACK d6b3640
  49. MarcoFalke commented at 12:50 pm on August 2, 2019: member

    ACK d6b3640ac732f6f66a8cb6761084d1beecc8a876

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3ACK d6b3640ac732f6f66a8cb6761084d1beecc8a876
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUjtHQwAlvgQph2uP/hqvyh4EGclSdMka8jVYUY56nEWpMuESGsZdo+OecyPiahc
     8HP2P5wvPIwUS6LF+HXzCLw9yxZY6KKZIqYOO2nG2mcP9KycMvcncopG+QyqOUxp/
     9hFVueMAoNFo8xfpodLq7/LjEIWt32F5FHyaLr4jBQZcxJo5nFBGtwBpzRVcK00LE
    10+YdXVacxCu9Q74ET99AlbBbQk5kVBuIuK1TYFsPQzQFsgp+L0ysOx697VSDFOHEW
    114RcTw/wrIbmg0ItVWq6Eq2ufJmHogY5mzurRPxli3ybm4+bSHVQbyiC+0sh++qx/
    12E1p03kuygA+lhImxwB3SpRBqUCyf+uR9vc7yMPjQ0p5izkOCNS5XHl31wwkGBl80
    13bJgF8KgqkkHQrHn/o/PzxLiixkIbZw0K+KU7+4Cl7r3Qio3b6SCCBF94tW7jg8hx
    14EsjpGUS7m+z4qZt91zPndcbCSxF5brfN/14LsVcYEoTF9YiU9Y6VbMSHEDrTG+vO
    15u+gEf0y3
    16=31Xg
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash 388665302574fab8386985975f35ab1e4733960dbf1495ad6009328b30e160eb -

  50. MarcoFalke referenced this in commit d759b5d26a on Aug 2, 2019
  51. MarcoFalke merged this on Aug 2, 2019
  52. MarcoFalke closed this on Aug 2, 2019

  53. fanquake removed the label Waiting for author on Aug 2, 2019
  54. Sjors deleted the branch on Aug 2, 2019
  55. sidhujag referenced this in commit d8b6c89365 on Aug 3, 2019
  56. fanquake commented at 8:20 am on August 14, 2019: member
    @Sjors Are you interested in backporting this?
  57. Sjors commented at 11:44 am on August 14, 2019: member
    @fanquake backporting to 0.18 in #16608
  58. fanquake removed the label Needs backport on Aug 14, 2019
  59. MarcoFalke referenced this in commit 00ffe5aca1 on Aug 19, 2019
  60. luke-jr referenced this in commit 365a50c414 on Sep 3, 2019
  61. Munkybooty referenced this in commit fa746f0f1d on Nov 25, 2021
  62. Munkybooty referenced this in commit 517021c93d on Nov 30, 2021
  63. DrahtBot locked this on Dec 16, 2021

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-07-06 04:12 UTC

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