RPC/Wallet: unloadwallet: Allow specifying wallet_name param matching RPC endpoint wallet #20448

pull luke-jr wants to merge 1 commits into bitcoin:master from luke-jr:unloadwallet_namematch changing 2 files +10 −5
  1. luke-jr commented at 7:15 PM on November 21, 2020: member

    Allow specifying the wallet_name param to unloadwallet on RPC wallet endpoints, so long as it matches the endpoint wallet.

  2. promag commented at 7:22 PM on November 21, 2020: member

    FWIW I thought about disallowing wallet_name when using a wallet endpoint.

  3. luke-jr commented at 7:25 PM on November 21, 2020: member

    That's what the current code does (and the first commit of this PR documents).

  4. DrahtBot added the label RPC/REST/ZMQ on Nov 21, 2020
  5. DrahtBot added the label Wallet on Nov 21, 2020
  6. MarcoFalke added the label Needs backport (0.21) on Nov 23, 2020
  7. MarcoFalke removed the label Needs backport (0.21) on Nov 23, 2020
  8. MarcoFalke commented at 6:55 AM on November 23, 2020: member

    would be easier to review and backport if the commit was a separate pull

  9. in test/functional/wallet_multiwallet.py:358 in 2e9ada5183 outdated
     354 | @@ -355,12 +355,18 @@ def wallet_file(name):
     355 |          assert_raises_rpc_error(-1, "JSON value is not a string as expected", self.nodes[0].unloadwallet)
     356 |          assert_raises_rpc_error(-18, "Requested wallet does not exist or is not loaded", self.nodes[0].unloadwallet, "dummy")
     357 |          assert_raises_rpc_error(-18, "Requested wallet does not exist or is not loaded", node.get_wallet_rpc("dummy").unloadwallet)
     358 | -        assert_raises_rpc_error(-8, "Cannot unload the requested wallet", w1.unloadwallet, "w2"),
     359 | +        assert_raises_rpc_error(-8, "RPC request wallet and wallet_name parameter specify different wallets", w1.unloadwallet, "w2"),
    


    jonatack commented at 7:49 AM on November 23, 2020:

    81162ec41e5ee2ce0 For the first commit, suggest testing with the same wallet name:

    -        assert_raises_rpc_error(-8, "Both the RPC request wallet and wallet_name parameter were provided (only one allowed)", w1.unloadwallet, "w2"),
    +        assert_raises_rpc_error(-8, "Both the RPC request wallet and wallet_name parameter were provided (only one allowed)", w1.unloadwallet, w1.getwalletinfo()["walletname"]),
    
  10. in src/wallet/rpcwallet.cpp:2809 in 2e9ada5183 outdated
    2805 | @@ -2806,8 +2806,8 @@ static RPCHelpMan unloadwallet()
    2806 |  {
    2807 |      std::string wallet_name;
    2808 |      if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) {
    2809 | -        if (!request.params[0].isNull()) {
    2810 | -            throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot unload the requested wallet");
    2811 | +        if (!(request.params[0].isNull() || request.params[0].get_str() == wallet_name)) {
    


    jonatack commented at 8:09 AM on November 23, 2020:

    2e9ada51830236a027371a48697b96 nit, would find this clearer

            if (!request.params[0].isNull() && request.params[0].get_str() != wallet_name) {
    

    luke-jr commented at 1:53 PM on November 23, 2020:

    That's strictly less clear (it relies on implicit precedence order)

  11. jonatack commented at 8:10 AM on November 23, 2020: member

    Approach ACK

  12. luke-jr commented at 1:51 PM on November 23, 2020: member

    @MarcoFalke Should I interpret that as a NACK to backporting the 2nd commit? (I said at least the first...)

  13. MarcoFalke commented at 2:00 PM on November 23, 2020: member

    Yes, feature freeze was a month ago

  14. DrahtBot commented at 9:55 PM on November 23, 2020: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  15. RPC/Wallet: unloadwallet: Allow specifying wallet_name param matching RPC endpoint 89bdad5b25
  16. MarcoFalke referenced this in commit 3a32b62fa7 on Nov 24, 2020
  17. DrahtBot added the label Needs rebase on Nov 24, 2020
  18. sidhujag referenced this in commit 94ee716b40 on Nov 24, 2020
  19. luke-jr force-pushed on Nov 24, 2020
  20. luke-jr renamed this:
    RPC/Wallet: unloadwallet: Allow specifying wallet_name param matching RPC request, and document behaviour
    RPC/Wallet: unloadwallet: Allow specifying wallet_name param matching RPC request
    on Nov 24, 2020
  21. luke-jr renamed this:
    RPC/Wallet: unloadwallet: Allow specifying wallet_name param matching RPC request
    RPC/Wallet: unloadwallet: Allow specifying wallet_name param matching RPC endpoint wallet
    on Nov 24, 2020
  22. luke-jr commented at 7:07 PM on November 24, 2020: member

    rebased

  23. DrahtBot removed the label Needs rebase on Nov 24, 2020
  24. jonatack commented at 8:10 PM on November 27, 2020: member

    ACK 89bdad5b25ae4ac03a486f729a5b58ae6f21946d

  25. MarcoFalke commented at 9:13 AM on November 28, 2020: member

    review ACK 89bdad5b25ae4ac03a486f729a5b58ae6f21946d

  26. MarcoFalke merged this on Nov 28, 2020
  27. MarcoFalke closed this on Nov 28, 2020

  28. sidhujag referenced this in commit 360bf12418 on Nov 28, 2020
  29. MarcoFalke locked this on Feb 15, 2022

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: 2026-04-13 15:14 UTC

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