This follows up on #18836 and #20282 to fix and improve the as-yet unreleased upgradewallet
feature and also implement review follow-up in #18836 (review).
This PR fixes 4 upgradewallet issues:
- this bug: #20403 (review)
- it returns nothing in the absence of an RPC error, which isn’t reassuring for users
- it returns the same thing both in the case of a successful upgrade and when no upgrade took place
- the error message object is currently dead code
This PR fixes the above and provides:
…user feedback to not silently return without upgrading
0{
1 "wallet_name": "disable private keys",
2 "previous_version": 169900,
3 "current_version": 169900,
4 "result": "Already at latest version. Wallet version unchanged."
5}
…better feedback after successfully upgrading
0{
1 "wallet_name": "watch-only",
2 "previous_version": 159900,
3 "current_version": 169900,
4 "result": "Wallet upgraded successfully from version 159900 to version 169900."
5}
…helpful error responses
0{
1 "wallet_name": "blank",
2 "previous_version": 169900,
3 "current_version": 169900,
4 "error": "Cannot downgrade wallet from version 169900 to version 159900. Wallet version unchanged."
5}
6{
7 "wallet_name": "blank",
8 "previous_version": 130000,
9 "current_version": 130000,
10 "error": "Cannot upgrade a non HD split wallet from version 130000 to version 169899 without upgrading to support pre-split keypool. Please use version 169900 or no version specified."
11}
updated help:
0upgradewallet ( version )
1
2Upgrade the wallet. Upgrades to the latest version if no version number is specified.
3New keys may be generated and a new wallet backup will need to be made.
4Arguments:
51. version (numeric, optional, default=169900) The version number to upgrade to. Default is the latest wallet version.
6
7Result:
8{ (json object)
9 "wallet_name" : "str", (string) Name of wallet this operation was performed on
10 "previous_version" : n, (numeric) Version of wallet before this operation
11 "current_version" : n, (numeric) Version of wallet after this operation
12 "result" : "str", (string, optional) Description of result, if no error
13 "error" : "str" (string, optional) Error message (if there is one)
14}