mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
Merge bitcoin/bitcoin#31072: refactor: Clean up messy strformat and bilingual_str usages
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / macOS 14 native, arm64, fuzz (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / Win64 native fuzz, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / macOS 14 native, arm64, fuzz (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / Win64 native fuzz, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
0184d33b3d
scripted-diff: Replace strprintf(Untranslated) with Untranslated(strprintf) (Ryan Ofsky)006e4d1d59
refactor: Use + instead of strformat to concatenate translated & untranslated strings (Ryan Ofsky)831d2bfcf9
refactor: Don't embed translated string in untranslated string. (Ryan Ofsky)058021969b
refactor: Avoid concatenation of format strings (Ryan Ofsky) Pull request description: This PR cleans up string formatting in the codebase so other PRs adding compile time checking can be simpler and easier to review (specifically #30928, #31061, #31074, and #31149). Currently these PRs are hard to review because in addition to changing formatting APIs, they have to update callers that are using the API's in unusual ways. Clean up these callers now so later PRs can be simpler. Specifically: - Use string literals instead of `std::string` format strings to enable more compile-time checking. - Avoid using untranslated bilingual strings as format strings. Use originals so they can by checked at compile time. - Favor `Untranslated(strprintf(...))` over `strprintf(Untranslated(...), ...)` for consistency and to prevent translated and untranslated strings from being unintentionally combined. ACKs for top commit: maflcko: lgtm ACK0184d33b3d
🔹 l0rinc: ACK0184d33b3d
- no overall difference because of the rebase Tree-SHA512: 37eb771187d30977f5f054eddb82af6dd69878ace89cede72032bb389e57200898119f9fe486ce6903ebb00cb24648be215ab3e44842b3d206b35e26038da750
This commit is contained in:
commit
22723c809a
14 changed files with 58 additions and 58 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
10
src/init.cpp
10
src/init.cpp
|
@ -886,7 +886,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
|
|||
}
|
||||
bilingual_str errors;
|
||||
for (const auto& arg : args.GetUnsuitableSectionOnlyArgs()) {
|
||||
errors += strprintf(_("Config setting for %s only applied on %s network when in [%s] section.") + Untranslated("\n"), arg, ChainTypeToString(chain), ChainTypeToString(chain));
|
||||
errors += strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, ChainTypeToString(chain), ChainTypeToString(chain)) + Untranslated("\n");
|
||||
}
|
||||
|
||||
if (!errors.empty()) {
|
||||
|
@ -901,7 +901,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
|
|||
// Warn if unrecognized section name are present in the config file.
|
||||
bilingual_str warnings;
|
||||
for (const auto& section : args.GetUnrecognizedSections()) {
|
||||
warnings += strprintf(Untranslated("%s:%i ") + _("Section [%s] is not recognized.") + Untranslated("\n"), section.m_file, section.m_line, section.m_name);
|
||||
warnings += Untranslated(strprintf("%s:%i ", section.m_file, section.m_line)) + strprintf(_("Section [%s] is not recognized."), section.m_name) + Untranslated("\n");
|
||||
}
|
||||
|
||||
if (!warnings.empty()) {
|
||||
|
@ -1208,7 +1208,7 @@ static ChainstateLoadResult InitAndLoadChainstate(
|
|||
try {
|
||||
node.chainman = std::make_unique<ChainstateManager>(*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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
10
src/net.cpp
10
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> 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
|
||||
|
|
|
@ -35,7 +35,7 @@ util::Result<void> 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<void> 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))};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ bool InitError(const bilingual_str& str, const std::vector<std::string>& details
|
|||
// functions which provide error details are ones that run during early init
|
||||
// before the GUI uiInterface is registered, so there's no point passing
|
||||
// main messages and details separately to uiInterface yet.
|
||||
return InitError(details.empty() ? str : strprintf(Untranslated("%s:\n%s"), str, MakeUnorderedList(details)));
|
||||
return InitError(details.empty() ? str : str + Untranslated(strprintf(":\n%s", MakeUnorderedList(details))));
|
||||
}
|
||||
|
||||
void InitWarning(const bilingual_str& str)
|
||||
|
|
|
@ -89,7 +89,7 @@ util::Result<void> 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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -42,7 +42,7 @@ util::Result<int> IntFn(int i, bool success)
|
|||
util::Result<bilingual_str> 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<NoCopy> NoCopyFn(int i, bool success)
|
||||
|
|
|
@ -5719,20 +5719,20 @@ util::Result<CBlockIndex*> 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) {
|
||||
|
@ -5811,7 +5811,7 @@ util::Result<CBlockIndex*> ChainstateManager::ActivateSnapshot(
|
|||
|
||||
if (auto res{this->PopulateAndValidateSnapshot(*snapshot_chainstate, coins_file, metadata)}; !res) {
|
||||
LOCK(::cs_main);
|
||||
return cleanup_bad_snapshot(strprintf(Untranslated("Population failed: %s"), util::ErrorString(res)));
|
||||
return cleanup_bad_snapshot(Untranslated(strprintf("Population failed: %s", util::ErrorString(res).original)));
|
||||
}
|
||||
|
||||
LOCK(::cs_main); // cs_main required for rest of snapshot activation.
|
||||
|
@ -5892,16 +5892,16 @@ util::Result<void> 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<void> ChainstateManager::PopulateAndValidateSnapshot(
|
|||
if (coin.nHeight > base_height ||
|
||||
outpoint.n >= std::numeric_limits<decltype(outpoint.n)>::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<void> 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<void> 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<void> 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);
|
||||
|
@ -6142,7 +6142,7 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
|
|||
|
||||
auto rename_result = m_snapshot_chainstate->InvalidateCoinsDBOnDisk();
|
||||
if (!rename_result) {
|
||||
user_error = strprintf(Untranslated("%s\n%s"), user_error, util::ErrorString(rename_result));
|
||||
user_error += Untranslated("\n") + util::ErrorString(rename_result);
|
||||
}
|
||||
|
||||
GetNotifications().fatalError(user_error);
|
||||
|
|
|
@ -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<CAmount> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -519,7 +519,7 @@ std::shared_ptr<CWallet> 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);
|
||||
|
|
Loading…
Reference in a new issue