From 4927a70d85cbbb70a25d85dd8a1d70c7d5274c11 Mon Sep 17 00:00:00 2001 From: willcl-ark Date: Thu, 25 Jan 2024 16:02:58 +0000 Subject: [PATCH] qt: remove util/translation.h --- src/Makefile.am | 2 - src/Makefile.test.include | 1 - src/addrdb.cpp | 5 +- src/banman.cpp | 3 +- src/bench/wallet_create.cpp | 4 +- src/bench/wallet_loading.cpp | 1 - src/bitcoin-chainstate.cpp | 12 +- src/bitcoin-cli.cpp | 3 - src/bitcoin-tx.cpp | 3 - src/bitcoin-util.cpp | 5 - src/bitcoin-wallet.cpp | 2 - src/bitcoind.cpp | 11 +- src/clientversion.cpp | 19 +- src/coins.h | 2 +- src/common/init.cpp | 13 +- src/common/init.h | 5 +- src/core_read.cpp | 2 +- src/core_write.cpp | 1 + src/external_signer.cpp | 1 + src/httpserver.cpp | 3 +- src/index/base.cpp | 3 +- src/init.cpp | 141 +++++----- src/init/common.cpp | 13 +- src/interfaces/chain.h | 5 +- src/interfaces/init.h | 2 +- src/interfaces/node.h | 8 +- src/interfaces/wallet.h | 11 +- src/kernel/bitcoinkernel.cpp | 10 - src/kernel/checks.cpp | 7 +- src/kernel/notifications_interface.h | 8 +- src/logging.cpp | 3 - src/logging.h | 1 - src/net.cpp | 41 ++- src/net.h | 3 +- src/net_permissions.cpp | 19 +- src/net_permissions.h | 6 +- src/node/abort.cpp | 7 +- src/node/abort.h | 4 +- src/node/blockmanager_args.cpp | 5 +- src/node/blockstorage.cpp | 5 +- src/node/chainstate.cpp | 37 ++- src/node/chainstate.h | 3 +- src/node/chainstatemanager_args.cpp | 3 +- src/node/connection_types.h | 4 +- src/node/interface_ui.cpp | 14 +- src/node/interface_ui.h | 11 +- src/node/interfaces.cpp | 7 +- src/node/kernel_notifications.cpp | 13 +- src/node/kernel_notifications.h | 7 +- src/node/mempool_args.cpp | 3 +- src/node/mempool_args.h | 1 - src/noui.cpp | 17 +- src/noui.h | 6 +- src/rpc/blockchain.cpp | 3 +- src/rpc/mining.cpp | 3 +- src/rpc/net.cpp | 3 +- src/rpc/rawtransaction_util.cpp | 9 +- src/rpc/rawtransaction_util.h | 3 +- src/rpc/util.cpp | 15 +- src/rpc/util.h | 3 +- src/script/sign.cpp | 13 +- src/script/sign.h | 3 +- src/test/fuzz/connman.cpp | 1 - src/test/fuzz/kitchen_sink.cpp | 1 - src/test/fuzz/net_permissions.cpp | 5 +- src/test/fuzz/script_sign.cpp | 3 +- src/test/fuzz/string.cpp | 9 +- src/test/fuzz/strprintf.cpp | 31 ++- src/test/netbase_tests.cpp | 11 +- src/test/result_tests.cpp | 35 +-- src/test/timedata_tests.cpp | 3 +- src/test/translation_tests.cpp | 21 -- src/test/util/setup_common.cpp | 4 +- src/test/util/txmempool.cpp | 1 - src/timedata.cpp | 3 +- src/txmempool.cpp | 25 +- src/util/error.cpp | 47 ++-- src/util/error.h | 12 +- src/util/result.h | 13 +- src/util/translation.h | 79 ------ src/validation.cpp | 49 ++-- src/validation.h | 3 +- src/wallet/bdb.cpp | 13 +- src/wallet/bdb.h | 8 +- src/wallet/coinselection.cpp | 4 +- src/wallet/db.h | 3 +- src/wallet/dump.cpp | 47 ++-- src/wallet/dump.h | 5 +- src/wallet/feebumper.cpp | 49 ++-- src/wallet/feebumper.h | 5 +- src/wallet/init.cpp | 1 - src/wallet/interfaces.cpp | 17 +- src/wallet/load.cpp | 29 +-- src/wallet/rpc/addresses.cpp | 5 +- src/wallet/rpc/backup.cpp | 7 +- src/wallet/rpc/spend.cpp | 27 +- src/wallet/rpc/util.cpp | 5 +- src/wallet/rpc/util.h | 3 +- src/wallet/rpc/wallet.cpp | 21 +- src/wallet/salvage.cpp | 19 +- src/wallet/salvage.h | 3 +- src/wallet/scriptpubkeyman.cpp | 27 +- src/wallet/scriptpubkeyman.h | 15 +- src/wallet/spend.cpp | 57 ++--- src/wallet/sqlite.cpp | 27 +- src/wallet/sqlite.h | 6 +- src/wallet/test/coinselector_tests.cpp | 5 +- src/wallet/test/db_tests.cpp | 3 +- src/wallet/test/fuzz/coinselection.cpp | 2 +- src/wallet/test/fuzz/notifications.cpp | 3 +- src/wallet/test/fuzz/scriptpubkeyman.cpp | 3 +- src/wallet/test/util.cpp | 8 +- src/wallet/test/wallet_tests.cpp | 7 +- src/wallet/test/walletdb_tests.cpp | 2 +- src/wallet/types.h | 9 +- src/wallet/wallet.cpp | 241 +++++++++--------- src/wallet/wallet.h | 26 +- src/wallet/walletdb.cpp | 17 +- src/wallet/wallettool.cpp | 27 +- src/warnings.cpp | 17 +- src/warnings.h | 5 +- .../test_framework/test_framework.py | 2 +- 122 files changed, 736 insertions(+), 981 deletions(-) delete mode 100644 src/kernel/bitcoinkernel.cpp delete mode 100644 src/test/translation_tests.cpp delete mode 100644 src/util/translation.h diff --git a/src/Makefile.am b/src/Makefile.am index f6fff1df6632c2..8b96473116a89c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -327,7 +327,6 @@ BITCOIN_CORE_H = \ util/tokenpipe.h \ util/trace.h \ util/transaction_identifier.h \ - util/translation.h \ util/types.h \ util/ui_change_type.h \ util/vector.h \ @@ -919,7 +918,6 @@ libbitcoinkernel_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -fvisibility=default # and more modules are decoupled from the consensus engine, this list will # shrink to only those which are absolutely necessary. libbitcoinkernel_la_SOURCES = \ - kernel/bitcoinkernel.cpp \ arith_uint256.cpp \ chain.cpp \ clientversion.cpp \ diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 46b9495fc1b63b..2bb716c1f5e4bf 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -153,7 +153,6 @@ BITCOIN_TESTS =\ test/timedata_tests.cpp \ test/torcontrol_tests.cpp \ test/transaction_tests.cpp \ - test/translation_tests.cpp \ test/txindex_tests.cpp \ test/txpackage_tests.cpp \ test/txreconciliation_tests.cpp \ diff --git a/src/addrdb.cpp b/src/addrdb.cpp index 8cf932bcb63969..1e10394e450b0a 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -22,7 +22,6 @@ #include #include #include -#include namespace { @@ -199,14 +198,14 @@ util::Result> LoadAddrman(const NetGroupManager& netgro DumpPeerAddresses(args, *addrman); } catch (const InvalidAddrManVersionError&) { if (!RenameOver(path_addr, (fs::path)path_addr + ".bak")) { - return util::Error{strprintf(_("Failed to rename invalid peers.dat file. Please move or delete it and try again."))}; + return util::Error{strprintf("Failed to rename invalid peers.dat file. Please move or delete it and try again.")}; } // Addrman can be in an inconsistent state after failure, reset it addrman = std::make_unique(netgroupman, /*deterministic=*/false, /*consistency_check_ratio=*/check_addrman); LogPrintf("Creating new peers.dat because the file version was not compatible (%s). Original backed up to peers.dat.bak\n", fs::quoted(fs::PathToString(path_addr))); DumpPeerAddresses(args, *addrman); } catch (const std::exception& e) { - return util::Error{strprintf(_("Invalid or corrupt peers.dat (%s). If you believe this is a bug, please report it to %s. As a workaround, you can move the file (%s) out of the way (rename, move, or delete) to have a new one created on the next start."), + return util::Error{strprintf("Invalid or corrupt peers.dat (%s). If you believe this is a bug, please report it to %s. As a workaround, you can move the file (%s) out of the way (rename, move, or delete) to have a new one created on the next start.", e.what(), PACKAGE_BUGREPORT, fs::quoted(fs::PathToString(path_addr)))}; } return addrman; diff --git a/src/banman.cpp b/src/banman.cpp index 9f668d76a311bf..6c9bafb9957e4a 100644 --- a/src/banman.cpp +++ b/src/banman.cpp @@ -11,7 +11,6 @@ #include #include #include -#include BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time) @@ -30,7 +29,7 @@ void BanMan::LoadBanlist() { LOCK(m_banned_mutex); - if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist…").translated); + if (m_client_interface) m_client_interface->InitMessage("Loading banlist…"); const auto start{SteadyClock::now()}; if (m_ban_db.Read(m_banned)) { diff --git a/src/bench/wallet_create.cpp b/src/bench/wallet_create.cpp index 993c4c4b3fde85..bd9880a9f8016f 100644 --- a/src/bench/wallet_create.cpp +++ b/src/bench/wallet_create.cpp @@ -29,8 +29,8 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted) } DatabaseStatus status; - bilingual_str error_string; - std::vector warnings; + std::string error_string; + std::vector warnings; fs::path wallet_path = test_setup->m_path_root / strprintf("test_wallet_%d", random.rand32()).c_str(); bench.run([&] { diff --git a/src/bench/wallet_loading.cpp b/src/bench/wallet_loading.cpp index b17c7fe05a8a34..bf602b23b290c3 100644 --- a/src/bench/wallet_loading.cpp +++ b/src/bench/wallet_loading.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp index ee8b0a44c52c6f..b8f6c8fa87d642 100644 --- a/src/bitcoin-chainstate.cpp +++ b/src/bitcoin-chainstate.cpp @@ -91,22 +91,22 @@ int main(int argc, char* argv[]) { std::cout << "Header tip changed: " << height << ", " << timestamp << ", " << presync << std::endl; } - void progress(const bilingual_str& title, int progress_percent, bool resume_possible) override + void progress(const std::string& title, int progress_percent, bool resume_possible) override { - std::cout << "Progress: " << title.original << ", " << progress_percent << ", " << resume_possible << std::endl; + std::cout << "Progress: " << title << ", " << progress_percent << ", " << resume_possible << std::endl; } - void warning(const bilingual_str& warning) override + void warning(const std::string& warning) override { - std::cout << "Warning: " << warning.original << std::endl; + std::cout << "Warning: " << warning << std::endl; } void flushError(const std::string& debug_message) override { std::cerr << "Error flushing block data to disk: " << debug_message << std::endl; } - void fatalError(const std::string& debug_message, const bilingual_str& user_message) override + void fatalError(const std::string& debug_message, const std::string& user_message) override { std::cerr << "Error: " << debug_message << std::endl; - std::cerr << (user_message.empty() ? "A fatal internal error occurred." : user_message.original) << std::endl; + std::cerr << (user_message.empty() ? "A fatal internal error occurred." : user_message) << std::endl; } }; auto notifications = std::make_unique(); diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index f0e27cb6750dac..ea23e7da3e5650 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -25,13 +25,11 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include @@ -50,7 +48,6 @@ // just use a plain system_clock. using CliClock = std::chrono::system_clock; -const std::function G_TRANSLATION_FUN = nullptr; UrlDecodeFn* const URL_DECODE = urlDecode; static const char DEFAULT_RPCCONNECT[] = "127.0.0.1"; diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 320624c419b803..c6082ab2350a20 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -28,17 +28,14 @@ #include #include #include -#include #include -#include #include static bool fCreateBlank; static std::map registers; static const int CONTINUE_EXECUTION=-1; -const std::function G_TRANSLATION_FUN = nullptr; static void SetupBitcoinTxArgs(ArgsManager &argsman) { diff --git a/src/bitcoin-util.cpp b/src/bitcoin-util.cpp index 96387e8c71e8a4..082a692b337ccd 100644 --- a/src/bitcoin-util.cpp +++ b/src/bitcoin-util.cpp @@ -18,18 +18,13 @@ #include #include #include -#include #include -#include #include -#include #include static const int CONTINUE_EXECUTION=-1; -const std::function G_TRANSLATION_FUN = nullptr; - static void SetupBitcoinUtilArgs(ArgsManager &argsman) { SetupHelpOptions(argsman); diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp index d5dfbbec2713a7..e74b5b0f965dac 100644 --- a/src/bitcoin-wallet.cpp +++ b/src/bitcoin-wallet.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -27,7 +26,6 @@ #include #include -const std::function G_TRANSLATION_FUN = nullptr; UrlDecodeFn* const URL_DECODE = nullptr; static void SetupWalletToolArgs(ArgsManager& argsman) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 4f0a816388e7f4..06a850a75a7d87 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -26,15 +26,12 @@ #include #include #include -#include #include -#include #include using node::NodeContext; -const std::function G_TRANSLATION_FUN = nullptr; UrlDecodeFn* const URL_DECODE = urlDecode; #if HAVE_DECL_FORK @@ -112,11 +109,10 @@ int fork_daemon(bool nochdir, bool noclose, TokenPipeEnd& endpoint) static bool ParseArgs(ArgsManager& args, int argc, char* argv[]) { - // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main() SetupServerArgs(args); std::string error; if (!args.ParseParameters(argc, argv, error)) { - return InitError(Untranslated(strprintf("Error parsing command line arguments: %s", error))); + return InitError(strprintf("Error parsing command line arguments: %s", error)); } if (auto error = common::InitConfig(args)) { @@ -126,7 +122,7 @@ static bool ParseArgs(ArgsManager& args, int argc, char* argv[]) // 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(Untranslated(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.", argv[i]))); + return InitError(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.", argv[i])); } } return true; @@ -169,7 +165,6 @@ static bool AppInit(NodeContext& node) std::any context{&node}; try { - // -server defaults to true for bitcoind but not for the GUI so do this here args.SoftSetBoolArg("-server", true); // Set this early so that parameter interactions go to console InitLogging(args); @@ -204,7 +199,7 @@ static bool AppInit(NodeContext& node) } break; case -1: // Error happened. - return InitError(Untranslated(strprintf("fork_daemon() failed: %s", SysErrorString(errno)))); + return InitError(strprintf("fork_daemon() failed: %s", SysErrorString(errno))); default: { // Parent: wait and exit. int token = daemon_ep.TokenRead(); if (token) { // Success diff --git a/src/clientversion.cpp b/src/clientversion.cpp index e7d63e34c6a3bc..04b8beea5cf302 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -3,7 +3,6 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#include #include @@ -12,9 +11,7 @@ #include /** - * Name of client reported in the 'version' message. Report the same name - * for both bitcoind and bitcoin-qt, to make it harder for attackers to - * target servers or GUI users specifically. + * Name of client reported in the 'version' message. */ const std::string CLIENT_NAME("Satoshi"); @@ -79,7 +76,7 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::string CopyrightHolders(const std::string& strPrefix) { - const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION); + const auto copyright_devs = strprintf(COPYRIGHT_HOLDERS, COPYRIGHT_HOLDERS_SUBSTITUTION); std::string strCopyrightHolders = strPrefix + copyright_devs; // Make sure Bitcoin Core copyright is not removed by accident @@ -93,15 +90,15 @@ std::string LicenseInfo() { const std::string URL_SOURCE_CODE = ""; - return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" + + return CopyrightHolders(strprintf("Copyright (C) %i-%i", 2009, COPYRIGHT_YEAR) + " ") + "\n" + "\n" + - strprintf(_("Please contribute if you find %s useful. " - "Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") + + strprintf("Please contribute if you find %s useful. " + "Visit %s for further information about the software.", PACKAGE_NAME, "<" PACKAGE_URL ">") + "\n" + - strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) + + strprintf("The source code is available from %s.", URL_SOURCE_CODE) + "\n" + "\n" + - _("This is experimental software.").translated + "\n" + - strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "") + + "This is experimental software." + "\n" + + strprintf("Distributed under the MIT software license, see the accompanying file %s or %s", "COPYING", "") + "\n"; } diff --git a/src/coins.h b/src/coins.h index c798cc38ba5a79..bf3933361166d8 100644 --- a/src/coins.h +++ b/src/coins.h @@ -368,7 +368,7 @@ const Coin& AccessByTxid(const CCoinsViewCache& cache, const Txid& txid); /** * This is a minimally invasive approach to shutdown on LevelDB read errors from the * chainstate, while keeping user interface out of the common library, which is shared - * between bitcoind, and bitcoin-qt and non-server tools. + * between bitcoind and non-server tools. * * Writes do not need similar protection, as failure to write is handled by the caller. */ diff --git a/src/common/init.cpp b/src/common/init.cpp index 412d73aec7016c..046a37b014bea8 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -19,7 +18,7 @@ std::optional InitConfig(ArgsManager& args, SettingsAbortFn setting { try { if (!CheckDataDirOption(args)) { - return ConfigError{ConfigStatus::FAILED, strprintf(_("Specified data directory \"%s\" does not exist."), args.GetArg("-datadir", ""))}; + return ConfigError{ConfigStatus::FAILED, strprintf("Specified data directory \"%s\" does not exist.", args.GetArg("-datadir", ""))}; } // Record original datadir and config paths before parsing the config @@ -36,7 +35,7 @@ std::optional InitConfig(ArgsManager& args, SettingsAbortFn setting std::string error; if (!args.ReadConfigFiles(error, true)) { - return ConfigError{ConfigStatus::FAILED, strprintf(_("Error reading configuration file: %s"), error)}; + return ConfigError{ConfigStatus::FAILED, strprintf("Error reading configuration file: %s", error)}; } // Check for chain settings (Params() calls are only valid after this clause) @@ -84,7 +83,7 @@ std::optional InitConfig(ArgsManager& args, SettingsAbortFn setting if (args.GetBoolArg("-allowignoredconf", false)) { LogPrintf("Warning: %s\n", error); } else { - return ConfigError{ConfigStatus::FAILED, Untranslated(error)}; + return ConfigError{ConfigStatus::FAILED, error}; } } @@ -92,7 +91,7 @@ std::optional InitConfig(ArgsManager& args, SettingsAbortFn setting if (args.GetSettingsPath()) { std::vector details; if (!args.ReadSettingsFile(&details)) { - const bilingual_str& message = _("Settings file could not be read"); + const std::string& message = "Settings file could not be read"; if (!settings_abort_fn) { return ConfigError{ConfigStatus::FAILED, message, details}; } else if (settings_abort_fn(message, details)) { @@ -102,12 +101,12 @@ std::optional InitConfig(ArgsManager& args, SettingsAbortFn setting } } if (!args.WriteSettingsFile(&details)) { - const bilingual_str& message = _("Settings file could not be written"); + const std::string& message = "Settings file could not be written"; return ConfigError{ConfigStatus::FAILED_WRITE, message, details}; } } } catch (const std::exception& e) { - return ConfigError{ConfigStatus::FAILED, Untranslated(e.what())}; + return ConfigError{ConfigStatus::FAILED, e.what()}; } return {}; } diff --git a/src/common/init.h b/src/common/init.h index 380ac3ac7e7089..9b3abb06e9864d 100644 --- a/src/common/init.h +++ b/src/common/init.h @@ -5,7 +5,6 @@ #ifndef BITCOIN_COMMON_INIT_H #define BITCOIN_COMMON_INIT_H -#include #include #include @@ -23,14 +22,14 @@ enum class ConfigStatus { struct ConfigError { ConfigStatus status; - bilingual_str message{}; + std::string message{}; std::vector details{}; }; //! Callback function to let the user decide whether to abort loading if //! settings.json file exists and can't be parsed, or to ignore the error and //! overwrite the file. -using SettingsAbortFn = std::function& details)>; +using SettingsAbortFn = std::function& details)>; /* Read config files, and create datadir and settings.json if they don't exist. */ std::optional InitConfig(ArgsManager& args, SettingsAbortFn settings_abort_fn = nullptr); diff --git a/src/core_read.cpp b/src/core_read.cpp index e32e46d1b9b4ab..d4923c52da202e 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -256,6 +256,6 @@ util::Result SighashFromStr(const std::string& sighash) if (it != map_sighash_values.end()) { return it->second; } else { - return util::Error{Untranslated(sighash + " is not a valid sighash parameter.")}; + return util::Error{sighash + " is not a valid sighash parameter."}; } } diff --git a/src/core_write.cpp b/src/core_write.cpp index 63f2c36b5af238..4844b9afbbfaa4 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -14,6 +14,7 @@ #include