mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
rpc: deprecate "warning" field in {create,load,unload,restore}wallet
This string field has been replaced in these four RPCs by a "warnings" field returning a JSON array of strings.
This commit is contained in:
parent
2f4a926e95
commit
645d7f75ac
4 changed files with 24 additions and 12 deletions
|
@ -1903,7 +1903,7 @@ RPCHelpMan restorewallet()
|
||||||
RPCResult::Type::OBJ, "", "",
|
RPCResult::Type::OBJ, "", "",
|
||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "name", "The wallet name if restored successfully."},
|
{RPCResult::Type::STR, "name", "The wallet name if restored successfully."},
|
||||||
{RPCResult::Type::STR, "warning", "Warning messages, if any, related to restoring the wallet. Multiple messages will be delimited by newlines."},
|
{RPCResult::Type::STR, "warning", /*optional=*/true, "Warning messages, if any, related to restoring the wallet. Multiple messages will be delimited by newlines. (DEPRECATED, returned only if config option -deprecatedrpc=walletwarningfield is passed.)"},
|
||||||
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to restoring the wallet.",
|
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to restoring the wallet.",
|
||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "", ""},
|
{RPCResult::Type::STR, "", ""},
|
||||||
|
@ -1937,7 +1937,9 @@ RPCHelpMan restorewallet()
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("name", wallet->GetName());
|
obj.pushKV("name", wallet->GetName());
|
||||||
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
|
||||||
|
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
||||||
|
}
|
||||||
PushWarnings(warnings, obj);
|
PushWarnings(warnings, obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|
|
@ -207,7 +207,7 @@ static RPCHelpMan loadwallet()
|
||||||
RPCResult::Type::OBJ, "", "",
|
RPCResult::Type::OBJ, "", "",
|
||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "name", "The wallet name if loaded successfully."},
|
{RPCResult::Type::STR, "name", "The wallet name if loaded successfully."},
|
||||||
{RPCResult::Type::STR, "warning", "Warning messages, if any, related to loading the wallet. Multiple messages will be delimited by newlines."},
|
{RPCResult::Type::STR, "warning", /*optional=*/true, "Warning messages, if any, related to loading the wallet. Multiple messages will be delimited by newlines. (DEPRECATED, returned only if config option -deprecatedrpc=walletwarningfield is passed.)"},
|
||||||
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to loading the wallet.",
|
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to loading the wallet.",
|
||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "", ""},
|
{RPCResult::Type::STR, "", ""},
|
||||||
|
@ -244,7 +244,9 @@ static RPCHelpMan loadwallet()
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("name", wallet->GetName());
|
obj.pushKV("name", wallet->GetName());
|
||||||
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
|
||||||
|
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
||||||
|
}
|
||||||
PushWarnings(warnings, obj);
|
PushWarnings(warnings, obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -340,7 +342,7 @@ static RPCHelpMan createwallet()
|
||||||
RPCResult::Type::OBJ, "", "",
|
RPCResult::Type::OBJ, "", "",
|
||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "name", "The wallet name if created successfully. If the wallet was created using a full path, the wallet_name will be the full path."},
|
{RPCResult::Type::STR, "name", "The wallet name if created successfully. If the wallet was created using a full path, the wallet_name will be the full path."},
|
||||||
{RPCResult::Type::STR, "warning", "Warning messages, if any, related to creating the wallet. Multiple messages will be delimited by newlines."},
|
{RPCResult::Type::STR, "warning", /*optional=*/true, "Warning messages, if any, related to creating the wallet. Multiple messages will be delimited by newlines. (DEPRECATED, returned only if config option -deprecatedrpc=walletwarningfield is passed.)"},
|
||||||
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to creating the wallet.",
|
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to creating the wallet.",
|
||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "", ""},
|
{RPCResult::Type::STR, "", ""},
|
||||||
|
@ -414,7 +416,9 @@ static RPCHelpMan createwallet()
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("name", wallet->GetName());
|
obj.pushKV("name", wallet->GetName());
|
||||||
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
|
||||||
|
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
||||||
|
}
|
||||||
PushWarnings(warnings, obj);
|
PushWarnings(warnings, obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -432,7 +436,7 @@ static RPCHelpMan unloadwallet()
|
||||||
{"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
|
{"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
|
||||||
},
|
},
|
||||||
RPCResult{RPCResult::Type::OBJ, "", "", {
|
RPCResult{RPCResult::Type::OBJ, "", "", {
|
||||||
{RPCResult::Type::STR, "warning", "Warning messages, if any, related to unloading the wallet. Multiple messages will be delimited by newlines."},
|
{RPCResult::Type::STR, "warning", /*optional=*/true, "Warning messages, if any, related to unloading the wallet. Multiple messages will be delimited by newlines. (DEPRECATED, returned only if config option -deprecatedrpc=walletwarningfield is passed.)"},
|
||||||
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to unloading the wallet.",
|
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to unloading the wallet.",
|
||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "", ""},
|
{RPCResult::Type::STR, "", ""},
|
||||||
|
@ -474,13 +478,13 @@ static RPCHelpMan unloadwallet()
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded");
|
throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UnloadWallet(std::move(wallet));
|
|
||||||
|
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
|
||||||
|
result.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
||||||
|
}
|
||||||
PushWarnings(warnings, result);
|
PushWarnings(warnings, result);
|
||||||
|
|
||||||
|
UnloadWallet(std::move(wallet));
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -265,7 +265,12 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
||||||
)
|
)
|
||||||
load_res = node_master.loadwallet("u1_v16")
|
load_res = node_master.loadwallet("u1_v16")
|
||||||
# Make sure this wallet opens without warnings. See https://github.com/bitcoin/bitcoin/pull/19054
|
# Make sure this wallet opens without warnings. See https://github.com/bitcoin/bitcoin/pull/19054
|
||||||
assert_equal(load_res['warning'], '')
|
if int(node_master.getnetworkinfo()["version"]) >= 249900:
|
||||||
|
# loadwallet#warnings (added in v25) -- only present if there is a warning
|
||||||
|
assert "warnings" not in load_res
|
||||||
|
else:
|
||||||
|
# loadwallet#warning (deprecated in v25) -- always present, but empty string if no warning
|
||||||
|
assert_equal(load_res["warning"], '')
|
||||||
wallet = node_master.get_wallet_rpc("u1_v16")
|
wallet = node_master.get_wallet_rpc("u1_v16")
|
||||||
info = wallet.getaddressinfo(v16_addr)
|
info = wallet.getaddressinfo(v16_addr)
|
||||||
descriptor = f"wpkh([{info['hdmasterfingerprint']}{hdkeypath[1:]}]{v16_pubkey})"
|
descriptor = f"wpkh([{info['hdmasterfingerprint']}{hdkeypath[1:]}]{v16_pubkey})"
|
||||||
|
|
|
@ -25,6 +25,7 @@ class CreateWalletTest(BitcoinTestFramework):
|
||||||
|
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
|
self.extra_args = [["-deprecatedrpc=walletwarningfield"]]
|
||||||
|
|
||||||
def skip_test_if_missing_module(self):
|
def skip_test_if_missing_module(self):
|
||||||
self.skip_if_no_wallet()
|
self.skip_if_no_wallet()
|
||||||
|
|
Loading…
Add table
Reference in a new issue