diff --git a/src/httpserver.cpp b/src/httpserver.cpp index e37bc21dea64c..88e640c377ccb 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -227,7 +227,7 @@ static bool InitHTTPAllowList() const CSubNet subnet{LookupSubNet(strAllow)}; if (!subnet.IsValid()) { uiInterface.ThreadSafeMessageBox( - strprintf(Untranslated("Invalid -rpcallowip subnet specification: %s. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24)."), strAllow), + Untranslated(strprintf("Invalid -rpcallowip subnet specification: %s. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24).", strAllow)), "", CClientUIInterface::MSG_ERROR); return false; } diff --git a/src/index/base.cpp b/src/index/base.cpp index 1a7eb9cd5e83b..a8f9073d9f4b1 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -106,7 +106,7 @@ bool BaseIndex::Init() // best chain, we will rewind to the fork point during index sync const CBlockIndex* locator_index{m_chainstate->m_blockman.LookupBlockIndex(locator.vHave.at(0))}; if (!locator_index) { - return InitError(strprintf(Untranslated("%s: best block of the index not found. Please rebuild the index."), GetName())); + return InitError(Untranslated(strprintf("%s: best block of the index not found. Please rebuild the index.", GetName()))); } SetBestBlockIndex(locator_index); } diff --git a/src/init.cpp b/src/init.cpp index 7182270de7774..a4ad2771cc7cf 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1208,7 +1208,7 @@ static ChainstateLoadResult InitAndLoadChainstate( try { node.chainman = std::make_unique(*Assert(node.shutdown_signal), chainman_opts, blockman_opts); } catch (std::exception& e) { - return {ChainstateLoadStatus::FAILURE_FATAL, strprintf(Untranslated("Failed to initialize ChainstateManager: %s"), e.what())}; + return {ChainstateLoadStatus::FAILURE_FATAL, Untranslated(strprintf("Failed to initialize ChainstateManager: %s", e.what()))}; } ChainstateManager& chainman = *node.chainman; // This is defined and set here instead of inline in validation.h to avoid a hard @@ -1339,7 +1339,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) try { ipc->listenAddress(address); } catch (const std::exception& e) { - return InitError(strprintf(Untranslated("Unable to bind to IPC address '%s'. %s"), address, e.what())); + return InitError(Untranslated(strprintf("Unable to bind to IPC address '%s'. %s", address, e.what()))); } LogPrintf("Listening for IPC requests on address %s\n", address); } @@ -2044,7 +2044,7 @@ bool StartIndexBackgroundSync(NodeContext& node) const CBlockIndex* start_block = *indexes_start_block; if (!start_block) start_block = chainman.ActiveChain().Genesis(); if (!chainman.m_blockman.CheckBlockDataAvailability(*index_chain.Tip(), *Assert(start_block))) { - return InitError(strprintf(Untranslated("%s best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)"), older_index_name)); + return InitError(Untranslated(strprintf("%s best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)", older_index_name))); } } diff --git a/src/init/common.cpp b/src/init/common.cpp index 3a8d75a626950..70c4230cfdb00 100644 --- a/src/init/common.cpp +++ b/src/init/common.cpp @@ -112,8 +112,8 @@ bool StartLogging(const ArgsManager& args) } } if (!LogInstance().StartLogging()) { - return InitError(strprintf(Untranslated("Could not open debug log file %s"), - fs::PathToString(LogInstance().m_file_path))); + return InitError(Untranslated(strprintf("Could not open debug log file %s", + fs::PathToString(LogInstance().m_file_path)))); } if (!LogInstance().m_log_timestamps) diff --git a/src/net.cpp b/src/net.cpp index 0f2e7e23d9080..802dc947bea9c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -3058,14 +3058,14 @@ bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError, socklen_t len = sizeof(sockaddr); if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len)) { - strError = strprintf(Untranslated("Bind address family for %s not supported"), addrBind.ToStringAddrPort()); + strError = Untranslated(strprintf("Bind address family for %s not supported", addrBind.ToStringAddrPort())); LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", strError.original); return false; } std::unique_ptr sock = CreateSock(addrBind.GetSAFamily(), SOCK_STREAM, IPPROTO_TCP); if (!sock) { - strError = strprintf(Untranslated("Couldn't open socket for incoming connections (socket returned error %s)"), NetworkErrorString(WSAGetLastError())); + strError = Untranslated(strprintf("Couldn't open socket for incoming connections (socket returned error %s)", NetworkErrorString(WSAGetLastError()))); LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", strError.original); return false; } @@ -3073,7 +3073,7 @@ bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError, // Allow binding if the port is still in TIME_WAIT state after // the program was closed and restarted. if (sock->SetSockOpt(SOL_SOCKET, SO_REUSEADDR, (sockopt_arg_type)&nOne, sizeof(int)) == SOCKET_ERROR) { - strError = strprintf(Untranslated("Error setting SO_REUSEADDR on socket: %s, continuing anyway"), NetworkErrorString(WSAGetLastError())); + strError = Untranslated(strprintf("Error setting SO_REUSEADDR on socket: %s, continuing anyway", NetworkErrorString(WSAGetLastError()))); LogPrintf("%s\n", strError.original); } @@ -3082,14 +3082,14 @@ bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError, if (addrBind.IsIPv6()) { #ifdef IPV6_V6ONLY if (sock->SetSockOpt(IPPROTO_IPV6, IPV6_V6ONLY, (sockopt_arg_type)&nOne, sizeof(int)) == SOCKET_ERROR) { - strError = strprintf(Untranslated("Error setting IPV6_V6ONLY on socket: %s, continuing anyway"), NetworkErrorString(WSAGetLastError())); + strError = Untranslated(strprintf("Error setting IPV6_V6ONLY on socket: %s, continuing anyway", NetworkErrorString(WSAGetLastError()))); LogPrintf("%s\n", strError.original); } #endif #ifdef WIN32 int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED; if (sock->SetSockOpt(IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char*)&nProtLevel, sizeof(int)) == SOCKET_ERROR) { - strError = strprintf(Untranslated("Error setting IPV6_PROTECTION_LEVEL on socket: %s, continuing anyway"), NetworkErrorString(WSAGetLastError())); + strError = Untranslated(strprintf("Error setting IPV6_PROTECTION_LEVEL on socket: %s, continuing anyway", NetworkErrorString(WSAGetLastError()))); LogPrintf("%s\n", strError.original); } #endif diff --git a/src/node/chainstatemanager_args.cpp b/src/node/chainstatemanager_args.cpp index cdc8bdd43e896..0ac96c55149a7 100644 --- a/src/node/chainstatemanager_args.cpp +++ b/src/node/chainstatemanager_args.cpp @@ -35,7 +35,7 @@ util::Result ApplyArgsManOptions(const ArgsManager& args, ChainstateManage if (auto min_work{uint256::FromUserHex(*value)}) { opts.minimum_chain_work = UintToArith256(*min_work); } else { - return util::Error{strprintf(Untranslated("Invalid minimum work specified (%s), must be up to %d hex digits"), *value, uint256::size() * 2)}; + return util::Error{Untranslated(strprintf("Invalid minimum work specified (%s), must be up to %d hex digits", *value, uint256::size() * 2))}; } } @@ -43,7 +43,7 @@ util::Result ApplyArgsManOptions(const ArgsManager& args, ChainstateManage if (auto block_hash{uint256::FromUserHex(*value)}) { opts.assumed_valid_block = *block_hash; } else { - return util::Error{strprintf(Untranslated("Invalid assumevalid block hash specified (%s), must be up to %d hex digits (or 0 to disable)"), *value, uint256::size() * 2)}; + return util::Error{Untranslated(strprintf("Invalid assumevalid block hash specified (%s), must be up to %d hex digits (or 0 to disable)", *value, uint256::size() * 2))}; } } diff --git a/src/node/mempool_args.cpp b/src/node/mempool_args.cpp index 0b6725ee1bee8..e3bf5fb57cbbc 100644 --- a/src/node/mempool_args.cpp +++ b/src/node/mempool_args.cpp @@ -89,7 +89,7 @@ util::Result ApplyArgsManOptions(const ArgsManager& argsman, const CChainP mempool_opts.require_standard = !argsman.GetBoolArg("-acceptnonstdtxn", DEFAULT_ACCEPT_NON_STD_TXN); if (!chainparams.IsTestChain() && !mempool_opts.require_standard) { - return util::Error{strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.GetChainTypeString())}; + return util::Error{Untranslated(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.GetChainTypeString()))}; } mempool_opts.persist_v1_dat = argsman.GetBoolArg("-persistmempoolv1", mempool_opts.persist_v1_dat); diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 59eeeb02cd026..eaaa9fc6fd5ba 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -529,7 +529,7 @@ int GuiMain(int argc, char* argv[]) SetupUIArgs(gArgs); std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { - InitError(strprintf(Untranslated("Error parsing command line arguments: %s"), error)); + InitError(Untranslated(strprintf("Error parsing command line arguments: %s", error))); // Create a message box, because the gui has neither been created nor has subscribed to core signals QMessageBox::critical(nullptr, CLIENT_NAME, // message cannot be translated because translations have not been initialized diff --git a/src/test/result_tests.cpp b/src/test/result_tests.cpp index 6a23a7b8950a9..68dace21dfddc 100644 --- a/src/test/result_tests.cpp +++ b/src/test/result_tests.cpp @@ -42,7 +42,7 @@ util::Result IntFn(int i, bool success) util::Result StrFn(bilingual_str s, bool success) { if (success) return s; - return util::Error{strprintf(Untranslated("str %s error."), s.original)}; + return util::Error{Untranslated(strprintf("str %s error.", s.original))}; } util::Result NoCopyFn(int i, bool success) diff --git a/src/validation.cpp b/src/validation.cpp index b3470ece491be..0227ccec2fd41 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5719,20 +5719,20 @@ util::Result ChainstateManager::ActivateSnapshot( if (!GetParams().AssumeutxoForBlockhash(base_blockhash).has_value()) { auto available_heights = GetParams().GetAvailableSnapshotHeights(); std::string heights_formatted = util::Join(available_heights, ", ", [&](const auto& i) { return util::ToString(i); }); - return util::Error{strprintf(Untranslated("assumeutxo block hash in snapshot metadata not recognized (hash: %s). The following snapshot heights are available: %s"), + return util::Error{Untranslated(strprintf("assumeutxo block hash in snapshot metadata not recognized (hash: %s). The following snapshot heights are available: %s", base_blockhash.ToString(), - heights_formatted)}; + heights_formatted))}; } snapshot_start_block = m_blockman.LookupBlockIndex(base_blockhash); if (!snapshot_start_block) { - return util::Error{strprintf(Untranslated("The base block header (%s) must appear in the headers chain. Make sure all headers are syncing, and call loadtxoutset again"), - base_blockhash.ToString())}; + return util::Error{Untranslated(strprintf("The base block header (%s) must appear in the headers chain. Make sure all headers are syncing, and call loadtxoutset again", + base_blockhash.ToString()))}; } bool start_block_invalid = snapshot_start_block->nStatus & BLOCK_FAILED_MASK; if (start_block_invalid) { - return util::Error{strprintf(Untranslated("The base block header (%s) is part of an invalid chain"), base_blockhash.ToString())}; + return util::Error{Untranslated(strprintf("The base block header (%s) is part of an invalid chain", base_blockhash.ToString()))}; } if (!m_best_header || m_best_header->GetAncestor(snapshot_start_block->nHeight) != snapshot_start_block) { @@ -5892,16 +5892,16 @@ util::Result ChainstateManager::PopulateAndValidateSnapshot( if (!snapshot_start_block) { // Needed for ComputeUTXOStats to determine the // height and to avoid a crash when base_blockhash.IsNull() - return util::Error{strprintf(Untranslated("Did not find snapshot start blockheader %s"), - base_blockhash.ToString())}; + return util::Error{Untranslated(strprintf("Did not find snapshot start blockheader %s", + base_blockhash.ToString()))}; } int base_height = snapshot_start_block->nHeight; const auto& maybe_au_data = GetParams().AssumeutxoForHeight(base_height); if (!maybe_au_data) { - return util::Error{strprintf(Untranslated("Assumeutxo height in snapshot metadata not recognized " - "(%d) - refusing to load snapshot"), base_height)}; + return util::Error{Untranslated(strprintf("Assumeutxo height in snapshot metadata not recognized " + "(%d) - refusing to load snapshot", base_height))}; } const AssumeutxoData& au_data = *maybe_au_data; @@ -5939,12 +5939,12 @@ util::Result ChainstateManager::PopulateAndValidateSnapshot( if (coin.nHeight > base_height || outpoint.n >= std::numeric_limits::max() // Avoid integer wrap-around in coinstats.cpp:ApplyHash ) { - return util::Error{strprintf(Untranslated("Bad snapshot data after deserializing %d coins"), - coins_count - coins_left)}; + return util::Error{Untranslated(strprintf("Bad snapshot data after deserializing %d coins", + coins_count - coins_left))}; } if (!MoneyRange(coin.out.nValue)) { - return util::Error{strprintf(Untranslated("Bad snapshot data after deserializing %d coins - bad tx out value"), - coins_count - coins_left)}; + return util::Error{Untranslated(strprintf("Bad snapshot data after deserializing %d coins - bad tx out value", + coins_count - coins_left))}; } coins_cache.EmplaceCoinInternalDANGER(std::move(outpoint), std::move(coin)); @@ -5982,8 +5982,8 @@ util::Result ChainstateManager::PopulateAndValidateSnapshot( } } } catch (const std::ios_base::failure&) { - return util::Error{strprintf(Untranslated("Bad snapshot format or truncated snapshot after deserializing %d coins"), - coins_processed)}; + return util::Error{Untranslated(strprintf("Bad snapshot format or truncated snapshot after deserializing %d coins", + coins_processed))}; } } @@ -6003,8 +6003,8 @@ util::Result ChainstateManager::PopulateAndValidateSnapshot( out_of_coins = true; } if (!out_of_coins) { - return util::Error{strprintf(Untranslated("Bad snapshot - coins left over after deserializing %d coins"), - coins_count)}; + return util::Error{Untranslated(strprintf("Bad snapshot - coins left over after deserializing %d coins", + coins_count))}; } LogPrintf("[snapshot] loaded %d (%.2f MB) coins from snapshot %s\n", @@ -6035,8 +6035,8 @@ util::Result ChainstateManager::PopulateAndValidateSnapshot( // Assert that the deserialized chainstate contents match the expected assumeutxo value. if (AssumeutxoHash{maybe_stats->hashSerialized} != au_data.hash_serialized) { - return util::Error{strprintf(Untranslated("Bad snapshot content hash: expected %s, got %s"), - au_data.hash_serialized.ToString(), maybe_stats->hashSerialized.ToString())}; + return util::Error{Untranslated(strprintf("Bad snapshot content hash: expected %s, got %s", + au_data.hash_serialized.ToString(), maybe_stats->hashSerialized.ToString()))}; } snapshot_chainstate.m_chain.SetTip(*snapshot_start_block); diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp index 68ad58d284027..b875461c9f2fe 100644 --- a/src/wallet/feebumper.cpp +++ b/src/wallet/feebumper.cpp @@ -46,7 +46,7 @@ static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWallet } if (wtx.mapValue.count("replaced_by_txid")) { - errors.push_back(strprintf(Untranslated("Cannot bump transaction %s which was already bumped by transaction %s"), wtx.GetHash().ToString(), wtx.mapValue.at("replaced_by_txid"))); + errors.push_back(Untranslated(strprintf("Cannot bump transaction %s which was already bumped by transaction %s", wtx.GetHash().ToString(), wtx.mapValue.at("replaced_by_txid")))); return feebumper::Result::WALLET_ERROR; } @@ -74,10 +74,10 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CMutableTrans CFeeRate minMempoolFeeRate = wallet.chain().mempoolMinFee(); if (newFeerate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) { - errors.push_back(strprintf( - Untranslated("New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- "), + errors.push_back(Untranslated( + strprintf("New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- ", FormatMoney(newFeerate.GetFeePerK()), - FormatMoney(minMempoolFeeRate.GetFeePerK()))); + FormatMoney(minMempoolFeeRate.GetFeePerK())))); return feebumper::Result::WALLET_ERROR; } @@ -89,7 +89,7 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CMutableTrans std::optional combined_bump_fee = wallet.chain().calculateCombinedBumpFee(reused_inputs, newFeerate); if (!combined_bump_fee.has_value()) { - errors.push_back(strprintf(Untranslated("Failed to calculate bump fees, because unconfirmed UTXOs depend on enormous cluster of unconfirmed transactions."))); + errors.push_back(Untranslated(strprintf("Failed to calculate bump fees, because unconfirmed UTXOs depend on enormous cluster of unconfirmed transactions."))); } CAmount new_total_fee = newFeerate.GetFee(maxTxSize) + combined_bump_fee.value(); @@ -99,23 +99,23 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CMutableTrans CAmount minTotalFee = old_fee + incrementalRelayFee.GetFee(maxTxSize); if (new_total_fee < minTotalFee) { - errors.push_back(strprintf(Untranslated("Insufficient total fee %s, must be at least %s (oldFee %s + incrementalFee %s)"), - FormatMoney(new_total_fee), FormatMoney(minTotalFee), FormatMoney(old_fee), FormatMoney(incrementalRelayFee.GetFee(maxTxSize)))); + errors.push_back(Untranslated(strprintf("Insufficient total fee %s, must be at least %s (oldFee %s + incrementalFee %s)", + FormatMoney(new_total_fee), FormatMoney(minTotalFee), FormatMoney(old_fee), FormatMoney(incrementalRelayFee.GetFee(maxTxSize))))); return feebumper::Result::INVALID_PARAMETER; } CAmount requiredFee = GetRequiredFee(wallet, maxTxSize); if (new_total_fee < requiredFee) { - errors.push_back(strprintf(Untranslated("Insufficient total fee (cannot be less than required fee %s)"), - FormatMoney(requiredFee))); + errors.push_back(Untranslated(strprintf("Insufficient total fee (cannot be less than required fee %s)", + FormatMoney(requiredFee)))); return feebumper::Result::INVALID_PARAMETER; } // Check that in all cases the new fee doesn't violate maxTxFee const CAmount max_tx_fee = wallet.m_default_max_tx_fee; if (new_total_fee > max_tx_fee) { - errors.push_back(strprintf(Untranslated("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)"), - FormatMoney(new_total_fee), FormatMoney(max_tx_fee))); + errors.push_back(Untranslated(strprintf("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)", + FormatMoney(new_total_fee), FormatMoney(max_tx_fee)))); return feebumper::Result::WALLET_ERROR; } diff --git a/src/wallet/salvage.cpp b/src/wallet/salvage.cpp index 457119396a5aa..b924239073c12 100644 --- a/src/wallet/salvage.cpp +++ b/src/wallet/salvage.cpp @@ -100,7 +100,7 @@ bool RecoverDatabaseFile(const ArgsManager& args, const fs::path& file_path, bil newFilename.c_str(), DB_AUTO_COMMIT); if (result != 0) { - error = strprintf(Untranslated("Failed to rename %s to %s"), filename, newFilename); + error = Untranslated(strprintf("Failed to rename %s to %s", filename, newFilename)); return false; } @@ -120,7 +120,7 @@ bool RecoverDatabaseFile(const ArgsManager& args, const fs::path& file_path, bil warnings.emplace_back(Untranslated("Salvage: Database salvage found errors, all data may not be recoverable.")); } if (result != 0 && result != DB_VERIFY_BAD) { - error = strprintf(Untranslated("Salvage: Database salvage failed with result %d."), result); + error = Untranslated(strprintf("Salvage: Database salvage failed with result %d.", result)); return false; } @@ -161,7 +161,7 @@ bool RecoverDatabaseFile(const ArgsManager& args, const fs::path& file_path, bil if (salvagedData.empty()) { - error = strprintf(Untranslated("Salvage(aggressive) found no records in %s."), newFilename); + error = Untranslated(strprintf("Salvage(aggressive) found no records in %s.", newFilename)); return false; } @@ -173,7 +173,7 @@ bool RecoverDatabaseFile(const ArgsManager& args, const fs::path& file_path, bil DB_CREATE, // Flags 0); if (ret > 0) { - error = strprintf(Untranslated("Cannot create database file %s"), filename); + error = Untranslated(strprintf("Cannot create database file %s", filename)); pdbCopy->close(0); return false; } @@ -204,7 +204,7 @@ bool RecoverDatabaseFile(const ArgsManager& args, const fs::path& file_path, bil if (!fReadOK) { - warnings.push_back(strprintf(Untranslated("WARNING: WalletBatch::Recover skipping %s: %s"), strType, strErr)); + warnings.push_back(Untranslated(strprintf("WARNING: WalletBatch::Recover skipping %s: %s", strType, strErr))); continue; } Dbt datKey(row.first.data(), row.first.size()); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c0341a8111434..56acf915d569f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -519,7 +519,7 @@ std::shared_ptr RestoreWallet(WalletContext& context, const fs::path& b } catch (const std::exception& e) { assert(!wallet); if (!error.empty()) error += Untranslated("\n"); - error += strprintf(Untranslated("Unexpected exception: %s"), e.what()); + error += Untranslated(strprintf("Unexpected exception: %s", e.what())); } if (!wallet) { fs::remove_all(wallet_path);