diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index 835b9b1b9f59f..c483b89cfb44d 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -534,7 +534,7 @@ RPCHelpMan importwallet() // Use uiInterface.ShowProgress instead of pwallet.ShowProgress because pwallet.ShowProgress has a cancel button tied to AbortRescan which // we don't want for this progress bar showing the import progress. uiInterface.ShowProgress does not have a cancel button. - pwallet->chain().showProgress(strprintf("%s %s", pwallet->GetDisplayName(), _("Importing…").translated), 0, false); // show progress dialog in GUI + pwallet->chain().showProgress(pwallet->TranslatedMessage(_("Importing…")), 0, false); // show progress dialog in GUI std::vector> keys; std::vector> scripts; while (file.good()) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 82c0d2caf1ec5..092b187777d49 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1897,7 +1897,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc fast_rescan_filter ? "fast variant using block filters" : "slow variant inspecting all blocks"); fAbortRescan = false; - ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…").translated), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption) + ShowProgress(TranslatedMessage(_("Rescanning…")), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption) uint256 tip_hash = WITH_LOCK(cs_wallet, return GetLastBlockHash()); uint256 end_hash = tip_hash; if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash)); @@ -1912,7 +1912,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc m_scanning_progress = 0; } if (block_height % 100 == 0 && progress_end - progress_begin > 0.0) { - ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…").translated), std::max(1, std::min(99, (int)(m_scanning_progress * 100)))); + ShowProgress(TranslatedMessage(_("Rescanning…")), std::max(1, std::min(99, (int)(m_scanning_progress * 100)))); } bool next_interval = reserver.now() >= current_time + INTERVAL_TIME; @@ -2009,7 +2009,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc WalletLogPrintf("Scanning current mempool transactions.\n"); WITH_LOCK(cs_wallet, chain().requestMempoolTransactions(*this)); } - ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…").translated), 100); // hide progress dialog in GUI + ShowProgress(TranslatedMessage(_("Rescanning…")), 100); // hide progress dialog in GUI if (block_height && fAbortRescan) { WalletLogPrintf("Rescan aborted at block %d. Progress=%f\n", block_height, progress_current); result.status = ScanResult::USER_ABORT; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d869f031bbf7b..2345b0361778a 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -929,6 +929,14 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati return strprintf("[%s]", wallet_name); }; + /** Return a translate message with the wallet name for use in ShowProgress. */ + std::string TranslatedMessage(const bilingual_str& message) + { + std::string name{GetName()}; + if (name.empty()) name = _("default wallet").translated; + return strprintf("[%s] %s", name, message.translated); + } + /** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */ template void WalletLogPrintf(util::ConstevalFormatString wallet_fmt, const Params&... params) const