From a9d64cd49c69dafd6496ccb5aef4cd6d8898966b Mon Sep 17 00:00:00 2001 From: David Gumberg Date: Tue, 27 May 2025 16:07:42 -0700 Subject: [PATCH] wallet: Remove redundant birth time update Checking every SPKM in `CWallet::Create()` is not necessary, since the only way presently for an SPKM to get added to `m_spk_managers` (the return value of `GetAllScriptPubKeyMans()`) is through `AddScriptPubKeyMan()`, which already invokes `MaybeUpdateBirthTime()`. --- src/wallet/wallet.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d30bdb7c511..a0138381d81 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3088,14 +3088,6 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri // Try to top up keypool. No-op if the wallet is locked. walletInstance->TopUpKeyPool(); - // Cache the first key time - std::optional time_first_key; - for (auto spk_man : walletInstance->GetAllScriptPubKeyMans()) { - int64_t time = spk_man->GetTimeFirstKey(); - if (!time_first_key || time < *time_first_key) time_first_key = time; - } - if (time_first_key) walletInstance->MaybeUpdateBirthTime(*time_first_key); - if (chain && !AttachChain(walletInstance, *chain, rescan_required, error, warnings)) { walletInstance->m_chain_notifications_handler.reset(); // Reset this pointer so that the wallet will actually be unloaded return nullptr;