diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index d2ac171f8d3..40e017600d1 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -996,7 +996,7 @@ bool DescriptorScriptPubKeyMan::TopUp(unsigned int size) WalletBatch batch(m_storage.GetDatabase()); if (!batch.TxnBegin()) return false; bool res = TopUpWithDB(batch, size); - if (!batch.TxnCommit()) throw std::runtime_error(strprintf("Error during descriptors keypool top up. Cannot commit changes for wallet %s", m_storage.GetDisplayName())); + if (!batch.TxnCommit()) throw std::runtime_error(strprintf("Error during descriptors keypool top up. Cannot commit changes for wallet [%s]", m_storage.LogName())); return res; } diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index e41ab6d669d..33c6ea3dcad 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -43,7 +43,7 @@ class WalletStorage { public: virtual ~WalletStorage() = default; - virtual std::string GetDisplayName() const = 0; + virtual std::string LogName() const = 0; virtual WalletDatabase& GetDatabase() const = 0; virtual bool IsWalletFlagSet(uint64_t) const = 0; virtual void UnsetBlankWalletFlag(WalletBatch&) = 0; @@ -162,7 +162,7 @@ public: template void WalletLogPrintf(util::ConstevalFormatString wallet_fmt, const Params&... params) const { - LogInfo("%s %s", m_storage.GetDisplayName(), tfm::format(wallet_fmt, params...)); + LogInfo("[%s] %s", m_storage.LogName(), tfm::format(wallet_fmt, params...)); }; /** Keypool has new keys */ diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index fa2833827c4..fc4c55fb7e9 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -905,14 +905,14 @@ public: /** Loads the flags into the wallet. (used by LoadWallet) */ bool LoadWalletFlags(uint64_t flags); - /** Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet has no name */ - std::string GetDisplayName() const override + /** Return wallet name for use in logs, will return "default wallet" if the wallet has no name. */ + std::string LogName() const override { - std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName(); - return strprintf("[%s]", wallet_name); + std::string name{GetName()}; + return name.empty() ? "default wallet" : name; }; - /** Return wallet name for display, translating "default wallet" string if returned. */ + /** Return wallet name for display, like LogName() but translates "default wallet" string. */ std::string DisplayName() const { std::string name{GetName()}; @@ -923,7 +923,7 @@ public: template void WalletLogPrintf(util::ConstevalFormatString wallet_fmt, const Params&... params) const { - LogInfo("%s %s", GetDisplayName(), tfm::format(wallet_fmt, params...)); + LogInfo("[%s] %s", LogName(), tfm::format(wallet_fmt, params...)); }; /** Upgrade the wallet */