mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
rpc: remove deprecated "warning" field from {create,load,restore,unload}wallet
Co-authored-by: Jon Atack <jon@atack.com>
This commit is contained in:
parent
7f2019755d
commit
a00ae31fcc
3 changed files with 4 additions and 27 deletions
|
@ -1909,7 +1909,6 @@ 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", /*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, "", ""},
|
||||||
|
@ -1943,9 +1942,6 @@ RPCHelpMan restorewallet()
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("name", wallet->GetName());
|
obj.pushKV("name", wallet->GetName());
|
||||||
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
|
|
||||||
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
|
||||||
}
|
|
||||||
PushWarnings(warnings, obj);
|
PushWarnings(warnings, obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|
|
@ -219,7 +219,6 @@ 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", /*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, "", ""},
|
||||||
|
@ -256,9 +255,6 @@ static RPCHelpMan loadwallet()
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("name", wallet->GetName());
|
obj.pushKV("name", wallet->GetName());
|
||||||
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
|
|
||||||
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
|
||||||
}
|
|
||||||
PushWarnings(warnings, obj);
|
PushWarnings(warnings, obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -354,7 +350,6 @@ 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", /*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, "", ""},
|
||||||
|
@ -428,9 +423,6 @@ static RPCHelpMan createwallet()
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("name", wallet->GetName());
|
obj.pushKV("name", wallet->GetName());
|
||||||
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
|
|
||||||
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
|
||||||
}
|
|
||||||
PushWarnings(warnings, obj);
|
PushWarnings(warnings, obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -448,7 +440,6 @@ 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", /*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, "", ""},
|
||||||
|
@ -490,13 +481,12 @@ static RPCHelpMan unloadwallet()
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded");
|
throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UniValue result(UniValue::VOBJ);
|
|
||||||
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
|
|
||||||
result.pushKV("warning", Join(warnings, Untranslated("\n")).original);
|
|
||||||
}
|
|
||||||
PushWarnings(warnings, result);
|
|
||||||
|
|
||||||
UnloadWallet(std::move(wallet));
|
UnloadWallet(std::move(wallet));
|
||||||
|
|
||||||
|
UniValue result(UniValue::VOBJ);
|
||||||
|
PushWarnings(warnings, result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,7 +25,6 @@ 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()
|
||||||
|
@ -164,7 +163,6 @@ class CreateWalletTest(BitcoinTestFramework):
|
||||||
assert_equal(walletinfo['keypoolsize_hd_internal'], keys)
|
assert_equal(walletinfo['keypoolsize_hd_internal'], keys)
|
||||||
# Allow empty passphrase, but there should be a warning
|
# Allow empty passphrase, but there should be a warning
|
||||||
resp = self.nodes[0].createwallet(wallet_name='w7', disable_private_keys=False, blank=False, passphrase='')
|
resp = self.nodes[0].createwallet(wallet_name='w7', disable_private_keys=False, blank=False, passphrase='')
|
||||||
assert_equal(resp["warning"], EMPTY_PASSPHRASE_MSG if self.options.descriptors else f"{EMPTY_PASSPHRASE_MSG}\n{LEGACY_WALLET_MSG}")
|
|
||||||
assert_equal(resp["warnings"], [EMPTY_PASSPHRASE_MSG] if self.options.descriptors else [EMPTY_PASSPHRASE_MSG, LEGACY_WALLET_MSG])
|
assert_equal(resp["warnings"], [EMPTY_PASSPHRASE_MSG] if self.options.descriptors else [EMPTY_PASSPHRASE_MSG, LEGACY_WALLET_MSG])
|
||||||
|
|
||||||
w7 = node.get_wallet_rpc('w7')
|
w7 = node.get_wallet_rpc('w7')
|
||||||
|
@ -184,21 +182,14 @@ class CreateWalletTest(BitcoinTestFramework):
|
||||||
result = self.nodes[0].createwallet(wallet_name="legacy_w0", descriptors=False, passphrase=None)
|
result = self.nodes[0].createwallet(wallet_name="legacy_w0", descriptors=False, passphrase=None)
|
||||||
assert_equal(result, {
|
assert_equal(result, {
|
||||||
"name": "legacy_w0",
|
"name": "legacy_w0",
|
||||||
"warning": LEGACY_WALLET_MSG,
|
|
||||||
"warnings": [LEGACY_WALLET_MSG],
|
"warnings": [LEGACY_WALLET_MSG],
|
||||||
})
|
})
|
||||||
result = self.nodes[0].createwallet(wallet_name="legacy_w1", descriptors=False, passphrase="")
|
result = self.nodes[0].createwallet(wallet_name="legacy_w1", descriptors=False, passphrase="")
|
||||||
assert_equal(result, {
|
assert_equal(result, {
|
||||||
"name": "legacy_w1",
|
"name": "legacy_w1",
|
||||||
"warning": f"{EMPTY_PASSPHRASE_MSG}\n{LEGACY_WALLET_MSG}",
|
|
||||||
"warnings": [EMPTY_PASSPHRASE_MSG, LEGACY_WALLET_MSG],
|
"warnings": [EMPTY_PASSPHRASE_MSG, LEGACY_WALLET_MSG],
|
||||||
})
|
})
|
||||||
|
|
||||||
self.log.info('Test "warning" field deprecation, i.e. not returned without -deprecatedrpc=walletwarningfield')
|
|
||||||
self.restart_node(0, extra_args=[])
|
|
||||||
result = self.nodes[0].createwallet(wallet_name="w7_again", disable_private_keys=False, blank=False, passphrase="")
|
|
||||||
assert "warning" not in result
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
CreateWalletTest().main()
|
CreateWalletTest().main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue