Skip to content

Commit 73972d5

Browse files
committed
Merge bitcoin/bitcoin#31296: wallet: Translate [default wallet] string in progress messages
db225ce wallet, refactor: Replace GetDisplayName() with LogName() (Ryan Ofsky) 0173788 wallet: Translate [default wallet] string in progress messages (Ryan Ofsky) Pull request description: Noticed while reviewing bitcoin/bitcoin#31287 (comment) that the [default wallet] part of progress messages remains untranslated while the rest of the string is translated. Fix this in all places where `CWallet::ShowProgress` (which has a cancel button) and `Chain::showProgress` (which doesn't have a cancel button) are called by making "default wallet" into a translated string. ACKs for top commit: achow101: ACK db225ce pablomartin4btc: ACK db225ce furszy: utACK db225ce Tree-SHA512: 3e76e22ee692a7403d61c66615f56d0fa5f7883dd47553bcaec2f9ffd942daaa90ceb61830206bece50da53dcd737b6438c36bcb086030b2deb68c44172f3931
2 parents ec484bd + db225ce commit 73972d5

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ bool DescriptorScriptPubKeyMan::TopUp(unsigned int size)
995995
WalletBatch batch(m_storage.GetDatabase());
996996
if (!batch.TxnBegin()) return false;
997997
bool res = TopUpWithDB(batch, size);
998-
if (!batch.TxnCommit()) throw std::runtime_error(strprintf("Error during descriptors keypool top up. Cannot commit changes for wallet %s", m_storage.GetDisplayName()));
998+
if (!batch.TxnCommit()) throw std::runtime_error(strprintf("Error during descriptors keypool top up. Cannot commit changes for wallet [%s]", m_storage.LogName()));
999999
return res;
10001000
}
10011001

src/wallet/scriptpubkeyman.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class WalletStorage
4343
{
4444
public:
4545
virtual ~WalletStorage() = default;
46-
virtual std::string GetDisplayName() const = 0;
46+
virtual std::string LogName() const = 0;
4747
virtual WalletDatabase& GetDatabase() const = 0;
4848
virtual bool IsWalletFlagSet(uint64_t) const = 0;
4949
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
@@ -153,7 +153,7 @@ class ScriptPubKeyMan
153153
template <typename... Params>
154154
void WalletLogPrintf(util::ConstevalFormatString<sizeof...(Params)> wallet_fmt, const Params&... params) const
155155
{
156-
LogInfo("%s %s", m_storage.GetDisplayName(), tfm::format(wallet_fmt, params...));
156+
LogInfo("[%s] %s", m_storage.LogName(), tfm::format(wallet_fmt, params...));
157157
};
158158

159159
/** Keypool has new keys */

src/wallet/wallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
17881788
fast_rescan_filter ? "fast variant using block filters" : "slow variant inspecting all blocks");
17891789

17901790
fAbortRescan = false;
1791-
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…")), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption)
1791+
ShowProgress(strprintf("[%s] %s", DisplayName(), _("Rescanning…")), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption)
17921792
uint256 tip_hash = WITH_LOCK(cs_wallet, return GetLastBlockHash());
17931793
uint256 end_hash = tip_hash;
17941794
if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash));
@@ -1803,7 +1803,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
18031803
m_scanning_progress = 0;
18041804
}
18051805
if (block_height % 100 == 0 && progress_end - progress_begin > 0.0) {
1806-
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…")), std::max(1, std::min(99, (int)(m_scanning_progress * 100))));
1806+
ShowProgress(strprintf("[%s] %s", DisplayName(), _("Rescanning…")), std::max(1, std::min(99, (int)(m_scanning_progress * 100))));
18071807
}
18081808

18091809
bool next_interval = reserver.now() >= current_time + INTERVAL_TIME;
@@ -1908,7 +1908,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
19081908
WalletLogPrintf("Scanning current mempool transactions.\n");
19091909
WITH_LOCK(cs_wallet, chain().requestMempoolTransactions(*this));
19101910
}
1911-
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…")), 100); // hide progress dialog in GUI
1911+
ShowProgress(strprintf("[%s] %s", DisplayName(), _("Rescanning…")), 100); // hide progress dialog in GUI
19121912
if (block_height && fAbortRescan) {
19131913
WalletLogPrintf("Rescan aborted at block %d. Progress=%f\n", block_height, progress_current);
19141914
result.status = ScanResult::USER_ABORT;

src/wallet/wallet.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,18 +931,25 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
931931
//! Retrieve all of the wallet's flags
932932
uint64_t GetWalletFlags() const;
933933

934-
/** Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet has no name */
935-
std::string GetDisplayName() const override
934+
/** Return wallet name for use in logs, will return "default wallet" if the wallet has no name. */
935+
std::string LogName() const override
936936
{
937-
std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName();
938-
return strprintf("[%s]", wallet_name);
937+
std::string name{GetName()};
938+
return name.empty() ? "default wallet" : name;
939+
};
940+
941+
/** Return wallet name for display, like LogName() but translates "default wallet" string. */
942+
std::string DisplayName() const
943+
{
944+
std::string name{GetName()};
945+
return name.empty() ? _("default wallet") : name;
939946
};
940947

941948
/** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */
942949
template <typename... Params>
943950
void WalletLogPrintf(util::ConstevalFormatString<sizeof...(Params)> wallet_fmt, const Params&... params) const
944951
{
945-
LogInfo("%s %s", GetDisplayName(), tfm::format(wallet_fmt, params...));
952+
LogInfo("[%s] %s", LogName(), tfm::format(wallet_fmt, params...));
946953
};
947954

948955
//! Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers

0 commit comments

Comments
 (0)