Skip to content

Commit

Permalink
rpc: drop newline escape sequences from wallet warning messages
Browse files Browse the repository at this point in the history
in RPCs createwallet, loadwallet, unloadwallet, and restorewallet.

Even if the newline escape sequence was operant, rather than being printed,
it doesn't make sense to separate sentences inside a JSON response string
field with newlines.

I believe only the createwallet RPC appends additional warning sentences
and is affected by this fix.
  • Loading branch information
jonatack committed Feb 21, 2023
1 parent 458c9f3 commit 6367e69
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/wallet/rpc/backup.cpp
Expand Up @@ -1926,7 +1926,7 @@ RPCHelpMan restorewallet()

UniValue obj(UniValue::VOBJ);
obj.pushKV("name", wallet->GetName());
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
obj.pushKV("warning", Join(/*container=*/warnings, /*separator=*/Untranslated(" ")).original);

return obj;

Expand Down
6 changes: 3 additions & 3 deletions src/wallet/rpc/wallet.cpp
Expand Up @@ -240,7 +240,7 @@ static RPCHelpMan loadwallet()

UniValue obj(UniValue::VOBJ);
obj.pushKV("name", wallet->GetName());
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
obj.pushKV("warning", Join(/*container=*/warnings, /*separator=*/Untranslated(" ")).original);

return obj;
},
Expand Down Expand Up @@ -405,7 +405,7 @@ static RPCHelpMan createwallet()

UniValue obj(UniValue::VOBJ);
obj.pushKV("name", wallet->GetName());
obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
obj.pushKV("warning", Join(/*container=*/warnings, /*separator=*/Untranslated(" ")).original);

return obj;
},
Expand Down Expand Up @@ -464,7 +464,7 @@ static RPCHelpMan unloadwallet()
UnloadWallet(std::move(wallet));

UniValue result(UniValue::VOBJ);
result.pushKV("warning", Join(warnings, Untranslated("\n")).original);
result.pushKV("warning", Join(/*container=*/warnings, /*separator=*/Untranslated(" ")).original);
return result;
},
};
Expand Down
2 changes: 1 addition & 1 deletion test/functional/wallet_createwallet.py
Expand Up @@ -17,7 +17,7 @@

LEGACY_WALLET_MSG = "Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future."
EMPTY_PASSPHRASE_MSG = "Empty string given as passphrase, wallet will not be encrypted."
EMPTY_PASSPHRASE_LEGACY_WALLET_MSG = f"{EMPTY_PASSPHRASE_MSG}\n{LEGACY_WALLET_MSG}"
EMPTY_PASSPHRASE_LEGACY_WALLET_MSG = f"{EMPTY_PASSPHRASE_MSG} {LEGACY_WALLET_MSG}"


class CreateWalletTest(BitcoinTestFramework):
Expand Down

0 comments on commit 6367e69

Please sign in to comment.