Skip to content

Commit

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

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

Currently, 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 ed0a983
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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 ed0a983

Please sign in to comment.