wallet: Remove redundant birth time update
What changed, and why it matters
This commit removes a small piece of code in Bitcoin Core's wallet startup that recalculated the wallet's 'birth time' (the earliest known key creation date) by scanning all script-pubkey managers. The author argues this recalculation is unnecessary because every path that adds a script-pubkey manager already calls the same birth-time update function. There is no indication in the commit that this fixes a security bug; it appears to be a code-cleanup/refactoring change.
No security action required. Treat as normal code cleanup. If reviewing for correctness, verify that all paths adding SPKMs to m_spk_managers indeed call MaybeUpdateBirthTime() and that no future SPKM addition path bypasses this invariant.
Security signals we found
No security-relevant keywords in commit title or message
Change is a removal of redundant logic, not a fix for a vulnerability
No mention of bug, crash, leak, bypass, or exploit in commit metadata
No advisory, CVE, or researcher attribution present in commit
Evidence from the diff
In CWallet::Create(), the removed block iterated over all SPKMs returned by GetAllScriptPubKeyMans(), found the minimum GetTimeFirstKey(), and called MaybeUpdateBirthTime() with it. The commit message states this is redundant because AddScriptPubKeyMan() already invokes MaybeUpdateBirthTime(). The change is purely subtractive (8 lines removed) and does not alter the SPKM addition paths or the birth-time update logic itself.
Changed components
src/wallet/wallet.cppCWallet::Create()wallet birth time trackingInspect captured patch +0 / −8
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index d30bdb7c..a0138381 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3088,14 +3088,6 @@ std::shared_ptr<CWallet> 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<int64_t> 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;
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.