Skip to content

Commit f0758d8

Browse files
committed
Merge bitcoin/bitcoin#27757: rpc: remove deprecated "warning" field from {create,load,restore,unload}wallet
5524fa0 doc: add release note about removal of `deprecatedrpc=walletwarningfield` flag (Sebastian Falbesoner) 5c77db7 Restorewallet/createwallet help documentation fixups/improvements (Jon Atack) a00ae31 rpc: remove deprecated "warning" field from {create,load,restore,unload}wallet (Sebastian Falbesoner) Pull request description: The "warning" string field for wallet creating/loading RPCs (`createwallet`, `loadwallet`, `unloadwallet` and `restorewallet`) has been deprecated with the configuration option `-deprecatedrpc=walletwarningfield` in PR #27279 (released in v25.0). For the next release v26.0, the field and the configuration option can be removed. ACKs for top commit: achow101: ACK 5524fa0 jonatack: ACK 5524fa0 Tree-SHA512: 8212f72067d08095304018b8a95d2ebef630004b65123483fbbfb078cc5709c2d825bbc35b16ea5f6b28ae7377347382d7e9afaf7bdbf0575d2c229d970784de
2 parents 1ecdf6e + 5524fa0 commit f0758d8

File tree

4 files changed

+16
-31
lines changed

4 files changed

+16
-31
lines changed

doc/release-notes-27757.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Wallet
2+
------
3+
4+
- The `deprecatedrpc=walletwarningfield` configuration option has been removed.
5+
The `createwallet`, `loadwallet`, `restorewallet` and `unloadwallet` RPCs no
6+
longer return the "warning" string field. The same information is provided
7+
through the "warnings" field added in v25.0, which returns a JSON array of
8+
strings. The "warning" string field was deprecated also in v25.0. (#27757)

src/wallet/rpc/backup.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ RPCHelpMan listdescriptors()
18621862
RPCHelpMan backupwallet()
18631863
{
18641864
return RPCHelpMan{"backupwallet",
1865-
"\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n",
1865+
"\nSafely copies the current wallet file to the specified destination, which can either be a directory or a path with a filename.\n",
18661866
{
18671867
{"destination", RPCArg::Type::STR, RPCArg::Optional::NO, "The destination directory or file"},
18681868
},
@@ -1897,7 +1897,7 @@ RPCHelpMan restorewallet()
18971897
{
18981898
return RPCHelpMan{
18991899
"restorewallet",
1900-
"\nRestore and loads a wallet from backup.\n"
1900+
"\nRestores and loads a wallet from backup.\n"
19011901
"\nThe rescan is significantly faster if a descriptor wallet is restored"
19021902
"\nand block filters are available (using startup option \"-blockfilterindex=1\").\n",
19031903
{
@@ -1909,8 +1909,7 @@ RPCHelpMan restorewallet()
19091909
RPCResult::Type::OBJ, "", "",
19101910
{
19111911
{RPCResult::Type::STR, "name", "The wallet name if restored successfully."},
1912-
{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.)"},
1913-
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to restoring the wallet.",
1912+
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to restoring and loading the wallet.",
19141913
{
19151914
{RPCResult::Type::STR, "", ""},
19161915
}},
@@ -1943,9 +1942,6 @@ RPCHelpMan restorewallet()
19431942

19441943
UniValue obj(UniValue::VOBJ);
19451944
obj.pushKV("name", wallet->GetName());
1946-
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
1947-
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
1948-
}
19491945
PushWarnings(warnings, obj);
19501946

19511947
return obj;

src/wallet/rpc/wallet.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ static RPCHelpMan loadwallet()
221221
RPCResult::Type::OBJ, "", "",
222222
{
223223
{RPCResult::Type::STR, "name", "The wallet name if loaded successfully."},
224-
{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.)"},
225224
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to loading the wallet.",
226225
{
227226
{RPCResult::Type::STR, "", ""},
@@ -258,9 +257,6 @@ static RPCHelpMan loadwallet()
258257

259258
UniValue obj(UniValue::VOBJ);
260259
obj.pushKV("name", wallet->GetName());
261-
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
262-
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
263-
}
264260
PushWarnings(warnings, obj);
265261

266262
return obj;
@@ -356,8 +352,7 @@ static RPCHelpMan createwallet()
356352
RPCResult::Type::OBJ, "", "",
357353
{
358354
{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."},
359-
{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.)"},
360-
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to creating the wallet.",
355+
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to creating and loading the wallet.",
361356
{
362357
{RPCResult::Type::STR, "", ""},
363358
}},
@@ -430,9 +425,6 @@ static RPCHelpMan createwallet()
430425

431426
UniValue obj(UniValue::VOBJ);
432427
obj.pushKV("name", wallet->GetName());
433-
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
434-
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
435-
}
436428
PushWarnings(warnings, obj);
437429

438430
return obj;
@@ -443,14 +435,13 @@ static RPCHelpMan createwallet()
443435
static RPCHelpMan unloadwallet()
444436
{
445437
return RPCHelpMan{"unloadwallet",
446-
"Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n"
438+
"Unloads the wallet referenced by the request endpoint, otherwise unloads the wallet specified in the argument.\n"
447439
"Specifying the wallet name on a wallet endpoint is invalid.",
448440
{
449441
{"wallet_name", RPCArg::Type::STR, RPCArg::DefaultHint{"the wallet name from the RPC endpoint"}, "The name of the wallet to unload. If provided both here and in the RPC endpoint, the two must be identical."},
450442
{"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."},
451443
},
452444
RPCResult{RPCResult::Type::OBJ, "", "", {
453-
{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.)"},
454445
{RPCResult::Type::ARR, "warnings", /*optional=*/true, "Warning messages, if any, related to unloading the wallet.",
455446
{
456447
{RPCResult::Type::STR, "", ""},
@@ -492,13 +483,12 @@ static RPCHelpMan unloadwallet()
492483
throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded");
493484
}
494485
}
486+
487+
UnloadWallet(std::move(wallet));
488+
495489
UniValue result(UniValue::VOBJ);
496-
if (wallet->chain().rpcEnableDeprecated("walletwarningfield")) {
497-
result.pushKV("warning", Join(warnings, Untranslated("\n")).original);
498-
}
499490
PushWarnings(warnings, result);
500491

501-
UnloadWallet(std::move(wallet));
502492
return result;
503493
},
504494
};

test/functional/wallet_createwallet.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def add_options(self, parser):
2525

2626
def set_test_params(self):
2727
self.num_nodes = 1
28-
self.extra_args = [["-deprecatedrpc=walletwarningfield"]]
2928

3029
def skip_test_if_missing_module(self):
3130
self.skip_if_no_wallet()
@@ -164,7 +163,6 @@ def run_test(self):
164163
assert_equal(walletinfo['keypoolsize_hd_internal'], keys)
165164
# Allow empty passphrase, but there should be a warning
166165
resp = self.nodes[0].createwallet(wallet_name='w7', disable_private_keys=False, blank=False, passphrase='')
167-
assert_equal(resp["warning"], EMPTY_PASSPHRASE_MSG if self.options.descriptors else f"{EMPTY_PASSPHRASE_MSG}\n{LEGACY_WALLET_MSG}")
168166
assert_equal(resp["warnings"], [EMPTY_PASSPHRASE_MSG] if self.options.descriptors else [EMPTY_PASSPHRASE_MSG, LEGACY_WALLET_MSG])
169167

170168
w7 = node.get_wallet_rpc('w7')
@@ -184,21 +182,14 @@ def run_test(self):
184182
result = self.nodes[0].createwallet(wallet_name="legacy_w0", descriptors=False, passphrase=None)
185183
assert_equal(result, {
186184
"name": "legacy_w0",
187-
"warning": LEGACY_WALLET_MSG,
188185
"warnings": [LEGACY_WALLET_MSG],
189186
})
190187
result = self.nodes[0].createwallet(wallet_name="legacy_w1", descriptors=False, passphrase="")
191188
assert_equal(result, {
192189
"name": "legacy_w1",
193-
"warning": f"{EMPTY_PASSPHRASE_MSG}\n{LEGACY_WALLET_MSG}",
194190
"warnings": [EMPTY_PASSPHRASE_MSG, LEGACY_WALLET_MSG],
195191
})
196192

197-
self.log.info('Test "warning" field deprecation, i.e. not returned without -deprecatedrpc=walletwarningfield')
198-
self.restart_node(0, extra_args=[])
199-
result = self.nodes[0].createwallet(wallet_name="w7_again", disable_private_keys=False, blank=False, passphrase="")
200-
assert "warning" not in result
201-
202193

203194
if __name__ == '__main__':
204195
CreateWalletTest().main()

0 commit comments

Comments
 (0)