From ca8cd893bb56bf5d455154b0498b1f58f77d20ed Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Tue, 17 Nov 2020 15:57:14 +0100 Subject: wallet: fix and improve upgradewallet error responses --- src/wallet/rpcwallet.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/wallet/rpcwallet.cpp') 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; -- cgit v1.2.3