mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Merge #20282: wallet: change upgradewallet return type to be an object
2ead31fb1b
[wallet] Return object from upgradewallet RPC (Sishir Giri) Pull request description: Change the return type of upgradewallet to be an object for future extensibility. Also return any error string returned from the `UpgradeWallet()` function. ACKs for top commit: MarcoFalke: ACK2ead31fb1b
meshcollider: Tested ACK2ead31fb1b
Tree-SHA512: bcc7432d2f35093ec2463ea19e894fa885b698c0e8d8e4bd2f979bd4d722cbfed53ec589d6280968917893c64649dc9e40800b8d854273b0f9a1380f51afbdb1
This commit is contained in:
commit
17c6fb176a
@ -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;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class UpgradeWalletTest(BitcoinTestFramework):
|
||||
|
||||
# calling upgradewallet without version arguments
|
||||
# should return nothing if successful
|
||||
assert_equal(wallet.upgradewallet(), "")
|
||||
assert_equal(wallet.upgradewallet(), {})
|
||||
new_version = wallet.getwalletinfo()["walletversion"]
|
||||
# upgraded wallet version should be greater than older one
|
||||
assert_greater_than(new_version, old_version)
|
||||
@ -130,7 +130,7 @@ class UpgradeWalletTest(BitcoinTestFramework):
|
||||
assert_equal('hdseedid' in wallet.getwalletinfo(), False)
|
||||
# calling upgradewallet with explicit version number
|
||||
# should return nothing if successful
|
||||
assert_equal(wallet.upgradewallet(169900), "")
|
||||
assert_equal(wallet.upgradewallet(169900), {})
|
||||
new_version = wallet.getwalletinfo()["walletversion"]
|
||||
# upgraded wallet should have version 169900
|
||||
assert_equal(new_version, 169900)
|
||||
|
Loading…
Reference in New Issue
Block a user