rpc, cli: improve error message on multiwallet mode

The primary objective is to provide users with clearer
and more informative error messages when encountering
the RPC_WALLET_NOT_SPECIFIED error, which occurs when
multiple wallets are loadad.

This commit also rectifies the error message consistency
by bringing the error message in line with the definition
established in protocol.h ("error when there are multiple
wallets loaded").
This commit is contained in:
pablomartin4btc
2023-01-29 17:48:49 -03:00
parent 225718eda8
commit 54227e681a
4 changed files with 15 additions and 5 deletions

View File

@@ -950,7 +950,8 @@ static void ParseError(const UniValue& error, std::string& strPrint, int& nRet)
strPrint += ("error message:\n" + err_msg.get_str());
}
if (err_code.isNum() && err_code.getInt<int>() == RPC_WALLET_NOT_SPECIFIED) {
strPrint += "\nTry adding \"-rpcwallet=<filename>\" option to bitcoin-cli command line.";
strPrint += " Or for the CLI, specify the \"-rpcwallet=<walletname>\" option before the command";
strPrint += " (run \"bitcoin-cli -h\" for help or \"bitcoin-cli listwallets\" to see which wallets are currently loaded).";
}
} else {
strPrint = "error: " + error.write();