This commit is contained in:
Ryan Ofsky 2025-04-29 12:00:33 +02:00 committed by GitHub
commit a43ecbbf04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 13 deletions

View file

@ -534,7 +534,7 @@ RPCHelpMan importwallet()
// Use uiInterface.ShowProgress instead of pwallet.ShowProgress because pwallet.ShowProgress has a cancel button tied to AbortRescan which // 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. // 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…")), 0, false); // show progress dialog in GUI pwallet->chain().showProgress(strprintf("[%s] %s", pwallet->DisplayName(), _("Importing…")), 0, false); // show progress dialog in GUI
std::vector<std::tuple<CKey, int64_t, bool, std::string>> keys; std::vector<std::tuple<CKey, int64_t, bool, std::string>> keys;
std::vector<std::pair<CScript, int64_t>> scripts; std::vector<std::pair<CScript, int64_t>> scripts;
while (file.good()) { while (file.good()) {

View file

@ -1317,7 +1317,7 @@ bool LegacyScriptPubKeyMan::TopUp(unsigned int kpSize)
return false; return false;
} }
} }
if (!batch.TxnCommit()) throw std::runtime_error(strprintf("Error during keypool top up. Cannot commit changes for wallet %s", m_storage.GetDisplayName())); if (!batch.TxnCommit()) throw std::runtime_error(strprintf("Error during keypool top up. Cannot commit changes for wallet [%s]", m_storage.LogName()));
NotifyCanGetAddressesChanged(); NotifyCanGetAddressesChanged();
// Note: Unlike with DescriptorSPKM, LegacySPKM does not need to call // Note: Unlike with DescriptorSPKM, LegacySPKM does not need to call
// m_storage.TopUpCallback() as we do not know what new scripts the LegacySPKM is // m_storage.TopUpCallback() as we do not know what new scripts the LegacySPKM is
@ -2250,7 +2250,7 @@ bool DescriptorScriptPubKeyMan::TopUp(unsigned int size)
WalletBatch batch(m_storage.GetDatabase()); WalletBatch batch(m_storage.GetDatabase());
if (!batch.TxnBegin()) return false; if (!batch.TxnBegin()) return false;
bool res = TopUpWithDB(batch, size); 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; return res;
} }

View file

@ -43,7 +43,7 @@ class WalletStorage
{ {
public: public:
virtual ~WalletStorage() = default; virtual ~WalletStorage() = default;
virtual std::string GetDisplayName() const = 0; virtual std::string LogName() const = 0;
virtual WalletDatabase& GetDatabase() const = 0; virtual WalletDatabase& GetDatabase() const = 0;
virtual bool IsWalletFlagSet(uint64_t) const = 0; virtual bool IsWalletFlagSet(uint64_t) const = 0;
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0; virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
@ -257,7 +257,7 @@ public:
template <typename... Params> template <typename... Params>
void WalletLogPrintf(util::ConstevalFormatString<sizeof...(Params)> wallet_fmt, const Params&... params) const void WalletLogPrintf(util::ConstevalFormatString<sizeof...(Params)> 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...));
}; };
/** Watch-only address added */ /** Watch-only address added */

View file

@ -1909,7 +1909,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
fast_rescan_filter ? "fast variant using block filters" : "slow variant inspecting all blocks"); fast_rescan_filter ? "fast variant using block filters" : "slow variant inspecting all blocks");
fAbortRescan = false; fAbortRescan = false;
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) 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)
uint256 tip_hash = WITH_LOCK(cs_wallet, return GetLastBlockHash()); uint256 tip_hash = WITH_LOCK(cs_wallet, return GetLastBlockHash());
uint256 end_hash = tip_hash; uint256 end_hash = tip_hash;
if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash)); if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash));
@ -1924,7 +1924,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
m_scanning_progress = 0; m_scanning_progress = 0;
} }
if (block_height % 100 == 0 && progress_end - progress_begin > 0.0) { if (block_height % 100 == 0 && progress_end - progress_begin > 0.0) {
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…")), std::max(1, std::min(99, (int)(m_scanning_progress * 100)))); ShowProgress(strprintf("[%s] %s", DisplayName(), _("Rescanning…")), std::max(1, std::min(99, (int)(m_scanning_progress * 100))));
} }
bool next_interval = reserver.now() >= current_time + INTERVAL_TIME; bool next_interval = reserver.now() >= current_time + INTERVAL_TIME;
@ -2029,7 +2029,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
WalletLogPrintf("Scanning current mempool transactions.\n"); WalletLogPrintf("Scanning current mempool transactions.\n");
WITH_LOCK(cs_wallet, chain().requestMempoolTransactions(*this)); WITH_LOCK(cs_wallet, chain().requestMempoolTransactions(*this));
} }
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…")), 100); // hide progress dialog in GUI ShowProgress(strprintf("[%s] %s", DisplayName(), _("Rescanning…")), 100); // hide progress dialog in GUI
if (block_height && fAbortRescan) { if (block_height && fAbortRescan) {
WalletLogPrintf("Rescan aborted at block %d. Progress=%f\n", block_height, progress_current); WalletLogPrintf("Rescan aborted at block %d. Progress=%f\n", block_height, progress_current);
result.status = ScanResult::USER_ABORT; result.status = ScanResult::USER_ABORT;

View file

@ -923,18 +923,25 @@ public:
/** Determine if we are a legacy wallet */ /** Determine if we are a legacy wallet */
bool IsLegacy() const; bool IsLegacy() const;
/** Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet has no name */ /** Return wallet name for use in logs, will return "default wallet" if the wallet has no name. */
std::string GetDisplayName() const override std::string LogName() const override
{ {
std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName(); std::string name{GetName()};
return strprintf("[%s]", wallet_name); return name.empty() ? "default wallet" : name;
};
/** Return wallet name for display, like LogName() but translates "default wallet" string. */
std::string DisplayName() const
{
std::string name{GetName()};
return name.empty() ? _("default wallet") : name;
}; };
/** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */ /** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */
template <typename... Params> template <typename... Params>
void WalletLogPrintf(util::ConstevalFormatString<sizeof...(Params)> wallet_fmt, const Params&... params) const void WalletLogPrintf(util::ConstevalFormatString<sizeof...(Params)> 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 */ /** Upgrade the wallet */