diff options
author | Jon Atack <jon@atack.com> | 2023-03-19 19:26:14 -0700 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2023-04-10 10:41:56 -0700 |
commit | 645d7f75ac1b40e4ea88119b3711f89943d35d6c (patch) | |
tree | 94fa05d0f6af85e0ef0e31ef2e62e9f44c7b4f80 /src | |
parent | 2f4a926e95e0379397859c3ba1b5711be5f09925 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/rpc/backup.cpp | 6 | ||||
-rw-r--r-- | src/wallet/rpc/wallet.cpp | 22 |
2 files changed, 17 insertions, 11 deletions
diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index 76a736d14d..fb175fa253 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -1903,7 +1903,7 @@ RPCHelpMan restorewallet() RPCResult::Type::OBJ, "", "", { {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::STR, "", ""}, @@ -1937,7 +1937,9 @@ RPCHelpMan restorewallet() UniValue obj(UniValue::VOBJ); 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); return obj; diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp index a28ddfb01b..d4aff4dfd6 100644 --- a/src/wallet/rpc/wallet.cpp +++ b/src/wallet/rpc/wallet.cpp @@ -207,7 +207,7 @@ static RPCHelpMan loadwallet() RPCResult::Type::OBJ, "", "", { {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::STR, "", ""}, @@ -244,7 +244,9 @@ static RPCHelpMan loadwallet() UniValue obj(UniValue::VOBJ); 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); return obj; @@ -340,7 +342,7 @@ static RPCHelpMan createwallet() 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, "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::STR, "", ""}, @@ -414,7 +416,9 @@ static RPCHelpMan createwallet() UniValue obj(UniValue::VOBJ); 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); 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."}, }, 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::STR, "", ""}, @@ -474,13 +478,13 @@ static RPCHelpMan unloadwallet() throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded"); } } - - UnloadWallet(std::move(wallet)); - 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); + UnloadWallet(std::move(wallet)); return result; }, }; |