[wallet] Return object from upgradewallet RPC

This commit is contained in:
Sishir Giri
2020-10-18 18:01:42 -07:00
committed by John Newbery
parent 867dbeba5f
commit 2ead31fb1b
2 changed files with 13 additions and 4 deletions

View File

@@ -4443,7 +4443,12 @@ static RPCHelpMan upgradewallet()
{
{"version", RPCArg::Type::NUM, /* default */ strprintf("%d", FEATURE_LATEST), "The version number to upgrade to. Default is the latest wallet version"}
},
RPCResults{},
RPCResult{
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "error", /* optional */ true, "Error message (if there is one)"}
},
},
RPCExamples{
HelpExampleCli("upgradewallet", "169900")
+ HelpExampleRpc("upgradewallet", "169900")
@@ -4468,7 +4473,11 @@ static RPCHelpMan upgradewallet()
if (!pwallet->UpgradeWallet(version, error, warnings)) {
throw JSONRPCError(RPC_WALLET_ERROR, error.original);
}
return error.original;
UniValue obj(UniValue::VOBJ);
if (!error.empty()) {
obj.pushKV("error", error.original);
}
return obj;
},
};
}