aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpcwallet.cpp
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2020-11-17 15:57:14 +0100
committerJon Atack <jon@atack.com>2020-11-19 20:00:53 +0100
commitca8cd893bb56bf5d455154b0498b1f58f77d20ed (patch)
tree6d3ed90574f06145e8bbe4646a3c9a8beea65f0f /src/wallet/rpcwallet.cpp
parent99d56e357159c7154f69f28cb5587c5ca20d6594 (diff)
wallet: fix and improve upgradewallet error responses
Diffstat (limited to 'src/wallet/rpcwallet.cpp')
-rw-r--r--src/wallet/rpcwallet.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index ef8281bfe2..2e3b34cbe3 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -4484,12 +4484,12 @@ static RPCHelpMan upgradewallet()
const int current_version{pwallet->GetVersion()};
std::string result;
- if (!wallet_upgraded) {
- throw JSONRPCError(RPC_WALLET_ERROR, error.original);
- } else if (previous_version == current_version) {
- result = "Already at latest version. Wallet version unchanged.";
- } else {
- result = strprintf("Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
+ if (wallet_upgraded) {
+ if (previous_version == current_version) {
+ result = "Already at latest version. Wallet version unchanged.";
+ } else {
+ result = strprintf("Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
+ }
}
UniValue obj(UniValue::VOBJ);
@@ -4498,8 +4498,8 @@ static RPCHelpMan upgradewallet()
obj.pushKV("current_version", current_version);
if (!result.empty()) {
obj.pushKV("result", result);
- }
- if (!error.empty()) {
+ } else {
+ CHECK_NONFATAL(!error.empty());
obj.pushKV("error", error.original);
}
return obj;