aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-04-11 18:48:04 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-05-05 04:46:04 +0300
commit7e923d47ba9891856b86bc9f718cf2f1f773bdf6 (patch)
treee4636c6b5209ed93b240dc1c23c58745f33fd1e8 /src
parent917ca93553917251e0fd59717a347c63cdfd8a14 (diff)
downloadbitcoin-7e923d47ba9891856b86bc9f718cf2f1f773bdf6.tar.xz
Make InitError bilingual
Diffstat (limited to 'src')
-rw-r--r--src/bitcoind.cpp14
-rw-r--r--src/init.cpp97
-rw-r--r--src/interfaces/chain.cpp2
-rw-r--r--src/interfaces/chain.h3
-rw-r--r--src/interfaces/node.cpp3
-rw-r--r--src/ui_interface.cpp5
-rw-r--r--src/ui_interface.h3
-rw-r--r--src/wallet/init.cpp6
-rw-r--r--src/wallet/load.cpp14
9 files changed, 74 insertions, 73 deletions
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 2aa416ca44..43d3f3c5ac 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -56,7 +56,7 @@ static bool AppInit(int argc, char* argv[])
SetupServerArgs(node);
std::string error;
if (!gArgs.ParseParameters(argc, argv, error)) {
- return InitError(strprintf("Error parsing command line arguments: %s\n", error));
+ return InitError(Untranslated(strprintf("Error parsing command line arguments: %s\n", error)));
}
// Process help and version before taking care about datadir
@@ -80,22 +80,22 @@ static bool AppInit(int argc, char* argv[])
try
{
if (!CheckDataDirOption()) {
- return InitError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")));
+ return InitError(Untranslated(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""))));
}
if (!gArgs.ReadConfigFiles(error, true)) {
- return InitError(strprintf("Error reading configuration file: %s\n", error));
+ return InitError(Untranslated(strprintf("Error reading configuration file: %s\n", error)));
}
// Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
try {
SelectParams(gArgs.GetChainName());
} catch (const std::exception& e) {
- return InitError(strprintf("%s\n", e.what()));
+ return InitError(Untranslated(strprintf("%s\n", e.what())));
}
// Error out when loose non-argument tokens are encountered on command line
for (int i = 1; i < argc; i++) {
if (!IsSwitchChar(argv[i][0])) {
- return InitError(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.\n", argv[i]));
+ return InitError(Untranslated(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.\n", argv[i])));
}
}
@@ -130,13 +130,13 @@ static bool AppInit(int argc, char* argv[])
// Daemonize
if (daemon(1, 0)) { // don't chdir (1), do close FDs (0)
- return InitError(strprintf("daemon() failed: %s\n", strerror(errno)));
+ return InitError(Untranslated(strprintf("daemon() failed: %s\n", strerror(errno))));
}
#if defined(MAC_OSX)
#pragma GCC diagnostic pop
#endif
#else
- return InitError("-daemon is not supported on this operating system\n");
+ return InitError(Untranslated("-daemon is not supported on this operating system\n"));
#endif // HAVE_DECL_DAEMON
}
// Lock data directory after daemonization
diff --git a/src/init.cpp b/src/init.cpp
index 51c80d1e2c..221cab15f8 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -121,7 +121,7 @@ NODISCARD static bool CreatePidFile()
#endif
return true;
} else {
- return InitError(strprintf(_("Unable to create the PID file '%s': %s").translated, GetPidFile().string(), std::strerror(errno)));
+ return InitError(strprintf(_("Unable to create the PID file '%s': %s"), GetPidFile().string(), std::strerror(errno)));
}
}
@@ -768,17 +768,15 @@ static void ThreadImport(std::vector<fs::path> vImportFiles)
*/
static bool InitSanityCheck()
{
- if(!ECC_InitSanityCheck()) {
- InitError("Elliptic curve cryptography sanity check failure. Aborting.");
- return false;
+ if (!ECC_InitSanityCheck()) {
+ return InitError(Untranslated("Elliptic curve cryptography sanity check failure. Aborting."));
}
if (!glibc_sanity_test() || !glibcxx_sanity_test())
return false;
if (!Random_SanityCheck()) {
- InitError("OS cryptographic RNG sanity check failure. Aborting.");
- return false;
+ return InitError(Untranslated("OS cryptographic RNG sanity check failure. Aborting."));
}
return true;
@@ -929,8 +927,9 @@ bool AppInitBasicSetup()
HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0);
#endif
- if (!SetupNetworking())
- return InitError("Initializing networking failed");
+ if (!SetupNetworking()) {
+ return InitError(Untranslated("Initializing networking failed."));
+ }
#ifndef WIN32
if (!gArgs.GetBoolArg("-sysperms", false)) {
@@ -967,7 +966,7 @@ bool AppInitParameterInteraction()
// on the command line or in this network's section of the config file.
std::string network = gArgs.GetChainName();
for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) {
- return InitError(strprintf(_("Config setting for %s only applied on %s network when in [%s] section.").translated, arg, network, network));
+ return InitError(strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, network, network));
}
// Warn if unrecognized section name are present in the config file.
@@ -976,7 +975,7 @@ bool AppInitParameterInteraction()
}
if (!fs::is_directory(GetBlocksDir())) {
- return InitError(strprintf(_("Specified blocks directory \"%s\" does not exist.").translated, gArgs.GetArg("-blocksdir", "")));
+ return InitError(strprintf(_("Specified blocks directory \"%s\" does not exist."), gArgs.GetArg("-blocksdir", "")));
}
// parse and validate enabled filter types
@@ -988,7 +987,7 @@ bool AppInitParameterInteraction()
for (const auto& name : names) {
BlockFilterType filter_type;
if (!BlockFilterTypeByName(name, filter_type)) {
- return InitError(strprintf(_("Unknown -blockfilterindex value %s.").translated, name));
+ return InitError(strprintf(_("Unknown -blockfilterindex value %s."), name));
}
g_enabled_filter_types.insert(filter_type);
}
@@ -997,16 +996,16 @@ bool AppInitParameterInteraction()
// if using block pruning, then disallow txindex
if (gArgs.GetArg("-prune", 0)) {
if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX))
- return InitError(_("Prune mode is incompatible with -txindex.").translated);
+ return InitError(_("Prune mode is incompatible with -txindex."));
if (!g_enabled_filter_types.empty()) {
- return InitError(_("Prune mode is incompatible with -blockfilterindex.").translated);
+ return InitError(_("Prune mode is incompatible with -blockfilterindex."));
}
}
// -bind and -whitebind can't be set when not listening
size_t nUserBind = gArgs.GetArgs("-bind").size() + gArgs.GetArgs("-whitebind").size();
if (nUserBind != 0 && !gArgs.GetBoolArg("-listen", DEFAULT_LISTEN)) {
- return InitError("Cannot set -bind or -whitebind together with -listen=0");
+ return InitError(Untranslated("Cannot set -bind or -whitebind together with -listen=0"));
}
// Make sure enough file descriptors are available
@@ -1024,7 +1023,7 @@ bool AppInitParameterInteraction()
#endif
nMaxConnections = std::max(std::min<int>(nMaxConnections, fd_max - nBind - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS), 0);
if (nFD < MIN_CORE_FILEDESCRIPTORS)
- return InitError(_("Not enough file descriptors available.").translated);
+ return InitError(_("Not enough file descriptors available."));
nMaxConnections = std::min(nFD - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS, nMaxConnections);
if (nMaxConnections < nUserMaxConnections)
@@ -1069,7 +1068,7 @@ bool AppInitParameterInteraction()
if (gArgs.IsArgSet("-minimumchainwork")) {
const std::string minChainWorkStr = gArgs.GetArg("-minimumchainwork", "");
if (!IsHexNumber(minChainWorkStr)) {
- return InitError(strprintf("Invalid non-hex (%s) minimum chain work value specified", minChainWorkStr));
+ return InitError(strprintf(Untranslated("Invalid non-hex (%s) minimum chain work value specified"), minChainWorkStr));
}
nMinimumChainWork = UintToArith256(uint256S(minChainWorkStr));
} else {
@@ -1084,21 +1083,21 @@ bool AppInitParameterInteraction()
int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
int64_t nMempoolSizeMin = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40;
if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
- return InitError(strprintf(_("-maxmempool must be at least %d MB").translated, std::ceil(nMempoolSizeMin / 1000000.0)));
+ return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
if (gArgs.IsArgSet("-incrementalrelayfee"))
{
CAmount n = 0;
if (!ParseMoney(gArgs.GetArg("-incrementalrelayfee", ""), n))
- return InitError(AmountErrMsg("incrementalrelayfee", gArgs.GetArg("-incrementalrelayfee", "")).translated);
+ return InitError(AmountErrMsg("incrementalrelayfee", gArgs.GetArg("-incrementalrelayfee", "")));
incrementalRelayFee = CFeeRate(n);
}
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
int64_t nPruneArg = gArgs.GetArg("-prune", 0);
if (nPruneArg < 0) {
- return InitError(_("Prune cannot be configured with a negative value.").translated);
+ return InitError(_("Prune cannot be configured with a negative value."));
}
nPruneTarget = (uint64_t) nPruneArg * 1024 * 1024;
if (nPruneArg == 1) { // manual pruning: -prune=1
@@ -1107,7 +1106,7 @@ bool AppInitParameterInteraction()
fPruneMode = true;
} else if (nPruneTarget) {
if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
- return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number.").translated, MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
+ return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
}
LogPrintf("Prune configured to target %u MiB on disk for block and undo files.\n", nPruneTarget / 1024 / 1024);
fPruneMode = true;
@@ -1120,13 +1119,13 @@ bool AppInitParameterInteraction()
peer_connect_timeout = gArgs.GetArg("-peertimeout", DEFAULT_PEER_CONNECT_TIMEOUT);
if (peer_connect_timeout <= 0) {
- return InitError("peertimeout cannot be configured with a negative value.");
+ return InitError(Untranslated("peertimeout cannot be configured with a negative value."));
}
if (gArgs.IsArgSet("-minrelaytxfee")) {
CAmount n = 0;
if (!ParseMoney(gArgs.GetArg("-minrelaytxfee", ""), n)) {
- return InitError(AmountErrMsg("minrelaytxfee", gArgs.GetArg("-minrelaytxfee", "")).translated);
+ return InitError(AmountErrMsg("minrelaytxfee", gArgs.GetArg("-minrelaytxfee", "")));
}
// High fee check is done afterward in CWallet::CreateWalletFromFile()
::minRelayTxFee = CFeeRate(n);
@@ -1142,7 +1141,7 @@ bool AppInitParameterInteraction()
{
CAmount n = 0;
if (!ParseMoney(gArgs.GetArg("-blockmintxfee", ""), n))
- return InitError(AmountErrMsg("blockmintxfee", gArgs.GetArg("-blockmintxfee", "")).translated);
+ return InitError(AmountErrMsg("blockmintxfee", gArgs.GetArg("-blockmintxfee", "")));
}
// Feerate used to define dust. Shouldn't be changed lightly as old
@@ -1151,13 +1150,13 @@ bool AppInitParameterInteraction()
{
CAmount n = 0;
if (!ParseMoney(gArgs.GetArg("-dustrelayfee", ""), n))
- return InitError(AmountErrMsg("dustrelayfee", gArgs.GetArg("-dustrelayfee", "")).translated);
+ return InitError(AmountErrMsg("dustrelayfee", gArgs.GetArg("-dustrelayfee", "")));
dustRelayFee = CFeeRate(n);
}
fRequireStandard = !gArgs.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
if (!chainparams.IsTestChain() && !fRequireStandard) {
- return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
+ return InitError(strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.NetworkIDString()));
}
nBytesPerSigOp = gArgs.GetArg("-bytespersigop", nBytesPerSigOp);
@@ -1174,10 +1173,10 @@ bool AppInitParameterInteraction()
nLocalServices = ServiceFlags(nLocalServices | NODE_BLOOM);
if (gArgs.GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) < 0)
- return InitError("rpcserialversion must be non-negative.");
+ return InitError(Untranslated("rpcserialversion must be non-negative."));
if (gArgs.GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) > 1)
- return InitError("unknown rpcserialversion requested.");
+ return InitError(Untranslated("Unknown rpcserialversion requested."));
nMaxTipAge = gArgs.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
@@ -1189,10 +1188,10 @@ static bool LockDataDirectory(bool probeOnly)
// Make sure only a single Bitcoin process is using the data directory.
fs::path datadir = GetDataDir();
if (!DirIsWritable(datadir)) {
- return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions.").translated, datadir.string()));
+ return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), datadir.string()));
}
if (!LockDirectory(datadir, ".lock", probeOnly)) {
- return InitError(strprintf(_("Cannot obtain a lock on data directory %s. %s is probably already running.").translated, datadir.string(), PACKAGE_NAME));
+ return InitError(strprintf(_("Cannot obtain a lock on data directory %s. %s is probably already running."), datadir.string(), PACKAGE_NAME));
}
return true;
}
@@ -1210,7 +1209,7 @@ bool AppInitSanityChecks()
// Sanity check
if (!InitSanityCheck())
- return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down.").translated, PACKAGE_NAME));
+ return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down."), PACKAGE_NAME));
// Probe the data directory lock to give an early error message, if possible
// We cannot hold the data directory lock here, as the forking for daemon() hasn't yet happened,
@@ -1246,7 +1245,7 @@ bool AppInitMain(NodeContext& node)
}
}
if (!LogInstance().StartLogging()) {
- return InitError(strprintf("Could not open debug log file %s",
+ return InitError(strprintf(Untranslated("Could not open debug log file %s"),
LogInstance().m_file_path.string()));
}
@@ -1346,7 +1345,7 @@ bool AppInitMain(NodeContext& node)
{
uiInterface.InitMessage_connect(SetRPCWarmupStatus);
if (!AppInitServers())
- return InitError(_("Unable to start HTTP server. See debug log for details.").translated);
+ return InitError(_("Unable to start HTTP server. See debug log for details."));
}
// ********************************************************* Step 5: verify wallet database integrity
@@ -1378,12 +1377,12 @@ bool AppInitMain(NodeContext& node)
std::vector<std::string> uacomments;
for (const std::string& cmt : gArgs.GetArgs("-uacomment")) {
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
- return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters.").translated, cmt));
+ return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
uacomments.push_back(cmt);
}
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments);
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
- return InitError(strprintf(_("Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments.").translated,
+ return InitError(strprintf(_("Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
}
@@ -1392,7 +1391,7 @@ bool AppInitMain(NodeContext& node)
for (const std::string& snet : gArgs.GetArgs("-onlynet")) {
enum Network net = ParseNetwork(snet);
if (net == NET_UNROUTABLE)
- return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'").translated, snet));
+ return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
nets.insert(net);
}
for (int n = 0; n < NET_MAX; n++) {
@@ -1413,12 +1412,12 @@ bool AppInitMain(NodeContext& node)
if (proxyArg != "" && proxyArg != "0") {
CService proxyAddr;
if (!Lookup(proxyArg, proxyAddr, 9050, fNameLookup)) {
- return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'").translated, proxyArg));
+ return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
}
proxyType addrProxy = proxyType(proxyAddr, proxyRandomize);
if (!addrProxy.IsValid())
- return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'").translated, proxyArg));
+ return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
SetProxy(NET_IPV4, addrProxy);
SetProxy(NET_IPV6, addrProxy);
@@ -1437,11 +1436,11 @@ bool AppInitMain(NodeContext& node)
} else {
CService onionProxy;
if (!Lookup(onionArg, onionProxy, 9050, fNameLookup)) {
- return InitError(strprintf(_("Invalid -onion address or hostname: '%s'").translated, onionArg));
+ return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
}
proxyType addrOnion = proxyType(onionProxy, proxyRandomize);
if (!addrOnion.IsValid())
- return InitError(strprintf(_("Invalid -onion address or hostname: '%s'").translated, onionArg));
+ return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
SetProxy(NET_ONION, addrOnion);
SetReachable(NET_ONION, true);
}
@@ -1457,7 +1456,7 @@ bool AppInitMain(NodeContext& node)
if (Lookup(strAddr, addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
AddLocal(addrLocal, LOCAL_MANUAL);
else
- return InitError(ResolveErrMsg("externalip", strAddr));
+ return InitError(Untranslated(ResolveErrMsg("externalip", strAddr)));
}
// Read asmap file if configured
@@ -1470,12 +1469,12 @@ bool AppInitMain(NodeContext& node)
asmap_path = GetDataDir() / asmap_path;
}
if (!fs::exists(asmap_path)) {
- InitError(strprintf(_("Could not find asmap file %s").translated, asmap_path));
+ InitError(strprintf(_("Could not find asmap file %s"), asmap_path));
return false;
}
std::vector<bool> asmap = CAddrMan::DecodeAsmap(asmap_path);
if (asmap.size() == 0) {
- InitError(strprintf(_("Could not parse asmap file %s").translated, asmap_path));
+ InitError(strprintf(_("Could not parse asmap file %s"), asmap_path));
return false;
}
const uint256 asmap_version = SerializeHash(asmap);
@@ -1581,7 +1580,7 @@ bool AppInitMain(NodeContext& node)
// (we're likely using a testnet datadir, or the other way around).
if (!::BlockIndex().empty() &&
!LookupBlockIndex(chainparams.GetConsensus().hashGenesisBlock)) {
- return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?").translated);
+ return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
}
// Check for changed -prune state. What we are concerned about is a user who has pruned blocks
@@ -1744,7 +1743,7 @@ bool AppInitMain(NodeContext& node)
return false;
}
} else {
- return InitError(strLoadError.translated);
+ return InitError(strLoadError);
}
}
}
@@ -1807,11 +1806,11 @@ bool AppInitMain(NodeContext& node)
// ********************************************************* Step 11: import blocks
if (!CheckDiskSpace(GetDataDir())) {
- InitError(strprintf(_("Error: Disk space is low for %s").translated, GetDataDir()));
+ InitError(strprintf(_("Error: Disk space is low for %s"), GetDataDir()));
return false;
}
if (!CheckDiskSpace(GetBlocksDir())) {
- InitError(strprintf(_("Error: Disk space is low for %s").translated, GetBlocksDir()));
+ InitError(strprintf(_("Error: Disk space is low for %s"), GetBlocksDir()));
return false;
}
@@ -1896,21 +1895,21 @@ bool AppInitMain(NodeContext& node)
for (const std::string& strBind : gArgs.GetArgs("-bind")) {
CService addrBind;
if (!Lookup(strBind, addrBind, GetListenPort(), false)) {
- return InitError(ResolveErrMsg("bind", strBind));
+ return InitError(Untranslated(ResolveErrMsg("bind", strBind)));
}
connOptions.vBinds.push_back(addrBind);
}
for (const std::string& strBind : gArgs.GetArgs("-whitebind")) {
NetWhitebindPermissions whitebind;
std::string error;
- if (!NetWhitebindPermissions::TryParse(strBind, whitebind, error)) return InitError(error);
+ if (!NetWhitebindPermissions::TryParse(strBind, whitebind, error)) return InitError(Untranslated(error));
connOptions.vWhiteBinds.push_back(whitebind);
}
for (const auto& net : gArgs.GetArgs("-whitelist")) {
NetWhitelistPermissions subnet;
std::string error;
- if (!NetWhitelistPermissions::TryParse(net, subnet, error)) return InitError(error);
+ if (!NetWhitelistPermissions::TryParse(net, subnet, error)) return InitError(Untranslated(error));
connOptions.vWhitelistedRange.push_back(subnet);
}
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp
index c5262e4bc0..515a2ba1b9 100644
--- a/src/interfaces/chain.cpp
+++ b/src/interfaces/chain.cpp
@@ -345,7 +345,7 @@ public:
int64_t getAdjustedTime() override { return GetAdjustedTime(); }
void initMessage(const std::string& message) override { ::uiInterface.InitMessage(message); }
void initWarning(const std::string& message) override { InitWarning(message); }
- void initError(const std::string& message) override { InitError(message); }
+ void initError(const bilingual_str& message) override { InitError(message); }
void showProgress(const std::string& title, int progress, bool resume_possible) override
{
::uiInterface.ShowProgress(title, progress, resume_possible);
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
index e33fe54ac8..77b315b195 100644
--- a/src/interfaces/chain.h
+++ b/src/interfaces/chain.h
@@ -21,6 +21,7 @@ class CScheduler;
class Coin;
class uint256;
enum class RBFTransactionState;
+struct bilingual_str;
struct CBlockLocator;
struct FeeCalculation;
struct NodeContext;
@@ -227,7 +228,7 @@ public:
virtual void initWarning(const std::string& message) = 0;
//! Send init error.
- virtual void initError(const std::string& message) = 0;
+ virtual void initError(const bilingual_str& message) = 0;
//! Send progress indicator.
virtual void showProgress(const std::string& title, int progress, bool resume_possible) = 0;
diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp
index 8564819e6a..9e603a12cd 100644
--- a/src/interfaces/node.cpp
+++ b/src/interfaces/node.cpp
@@ -28,6 +28,7 @@
#include <txmempool.h>
#include <ui_interface.h>
#include <util/system.h>
+#include <util/translation.h>
#include <validation.h>
#include <warnings.h>
@@ -54,7 +55,7 @@ namespace {
class NodeImpl : public Node
{
public:
- void initError(const std::string& message) override { InitError(message); }
+ void initError(const std::string& message) override { InitError(Untranslated(message)); }
bool parseParameters(int argc, const char* const argv[], std::string& error) override
{
return gArgs.ParseParameters(argc, argv, error);
diff --git a/src/ui_interface.cpp b/src/ui_interface.cpp
index ec8c969fc5..9cfde9502d 100644
--- a/src/ui_interface.cpp
+++ b/src/ui_interface.cpp
@@ -53,10 +53,9 @@ void CClientUIInterface::NotifyBlockTip(bool b, const CBlockIndex* i) { return g
void CClientUIInterface::NotifyHeaderTip(bool b, const CBlockIndex* i) { return g_ui_signals.NotifyHeaderTip(b, i); }
void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); }
-
-bool InitError(const std::string& str)
+bool InitError(const bilingual_str& str)
{
- uiInterface.ThreadSafeMessageBox(Untranslated(str), "", CClientUIInterface::MSG_ERROR);
+ uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
return false;
}
diff --git a/src/ui_interface.h b/src/ui_interface.h
index 9e4290ae95..132866cc5a 100644
--- a/src/ui_interface.h
+++ b/src/ui_interface.h
@@ -120,10 +120,11 @@ public:
};
/** Show warning message **/
+// TODO: InitWarning() should take a bilingual_str parameter.
void InitWarning(const std::string& str);
/** Show error message **/
-bool InitError(const std::string& str);
+bool InitError(const bilingual_str& str);
extern CClientUIInterface uiInterface;
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index 8688f3df5e..6f973aab1c 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -91,7 +91,7 @@ bool WalletInit::ParameterInteraction() const
if (gArgs.GetBoolArg("-salvagewallet", false)) {
if (is_multiwallet) {
- return InitError(strprintf("%s is only allowed with a single wallet file", "-salvagewallet"));
+ return InitError(strprintf(Untranslated("%s is only allowed with a single wallet file"), "-salvagewallet"));
}
// Rewrite just private keys: rescan to find transactions
if (gArgs.SoftSetBoolArg("-rescan", true)) {
@@ -108,7 +108,7 @@ bool WalletInit::ParameterInteraction() const
// -zapwallettxes implies a rescan
if (zapwallettxes) {
if (is_multiwallet) {
- return InitError(strprintf("%s is only allowed with a single wallet file", "-zapwallettxes"));
+ return InitError(strprintf(Untranslated("%s is only allowed with a single wallet file"), "-zapwallettxes"));
}
if (gArgs.SoftSetBoolArg("-rescan", true)) {
LogPrintf("%s: parameter interaction: -zapwallettxes enabled -> setting -rescan=1\n", __func__);
@@ -116,7 +116,7 @@ bool WalletInit::ParameterInteraction() const
}
if (gArgs.GetBoolArg("-sysperms", false))
- return InitError("-sysperms is not allowed in combination with enabled wallet functionality");
+ return InitError(Untranslated("-sysperms is not allowed in combination with enabled wallet functionality"));
return true;
}
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp
index 217a950457..45841b2ae1 100644
--- a/src/wallet/load.cpp
+++ b/src/wallet/load.cpp
@@ -20,14 +20,14 @@ bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wal
// The canonical path cleans the path, preventing >1 Berkeley environment instances for the same directory
fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error);
if (error || !fs::exists(wallet_dir)) {
- chain.initError(strprintf(_("Specified -walletdir \"%s\" does not exist").translated, wallet_dir.string()));
+ chain.initError(strprintf(_("Specified -walletdir \"%s\" does not exist"), wallet_dir.string()));
return false;
} else if (!fs::is_directory(wallet_dir)) {
- chain.initError(strprintf(_("Specified -walletdir \"%s\" is not a directory").translated, wallet_dir.string()));
+ chain.initError(strprintf(_("Specified -walletdir \"%s\" is not a directory"), wallet_dir.string()));
return false;
// The canonical path transforms relative paths into absolute ones, so we check the non-canonical version
} else if (!wallet_dir.is_absolute()) {
- chain.initError(strprintf(_("Specified -walletdir \"%s\" is a relative path").translated, wallet_dir.string()));
+ chain.initError(strprintf(_("Specified -walletdir \"%s\" is a relative path"), wallet_dir.string()));
return false;
}
gArgs.ForceSetArg("-walletdir", canonical_wallet_dir.string());
@@ -49,7 +49,7 @@ bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wal
WalletLocation location(wallet_file);
if (!wallet_paths.insert(location.GetPath()).second) {
- chain.initError(strprintf(_("Error loading wallet %s. Duplicate -wallet filename specified.").translated, wallet_file));
+ chain.initError(strprintf(_("Error loading wallet %s. Duplicate -wallet filename specified."), wallet_file));
return false;
}
@@ -58,7 +58,7 @@ bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wal
bool verify_success = CWallet::Verify(chain, location, salvage_wallet, error_string, warnings);
if (!warnings.empty()) chain.initWarning(Join(warnings, "\n", OpTranslated));
if (!verify_success) {
- chain.initError(error_string.translated);
+ chain.initError(error_string);
return false;
}
}
@@ -75,14 +75,14 @@ bool LoadWallets(interfaces::Chain& chain, const std::vector<std::string>& walle
std::shared_ptr<CWallet> pwallet = CWallet::CreateWalletFromFile(chain, WalletLocation(walletFile), error, warnings);
if (!warnings.empty()) chain.initWarning(Join(warnings, "\n", OpTranslated));
if (!pwallet) {
- chain.initError(error.translated);
+ chain.initError(error);
return false;
}
AddWallet(pwallet);
}
return true;
} catch (const std::runtime_error& e) {
- chain.initError(e.what());
+ chain.initError(Untranslated(e.what()));
return false;
}
}