wallet: Correctly log stats for encrypted messages.
What changed, and why it matters
This commit fixes a minor wallet logging bug. When creating an encrypted wallet, the keypool size was incorrectly reported as 0 in the logs because statistics were logged before the encryption keys were generated. The fix moves the logging to after wallet creation is fully complete and also updates a user-facing status message from 'Loading wallet…' to 'Creating wallet…' for accuracy. There is no security vulnerability here—only a cosmetic/logging correction.
No security action required. Treat as a normal bugfix/logging improvement.
Security signals we found
No security-relevant code change
Logging/statistics correction only
No input validation, authentication, authorization, or cryptography changes
Evidence from the diff
The change moves the WITH_LOCK(wallet->cs_wallet, wallet->LogStats()) call from the end of CWallet::Create() to the end of CreateWallet(), after encrypted wallet setup (TopUpKeyPool) has completed. It also corrects an initMessage string. This ensures LogStats() reports the actual keypool size rather than 0 for newly created encrypted wallets. No cryptographic, consensus, or network code is modified.
Changed components
src/wallet/wallet.cppWallet creation loggingEncrypted wallet keypool statistics reportingInspect captured patch +2 / −3
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index a11f8511..d7663ed0 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -413,7 +413,7 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
}
// Make the wallet
- context.chain->initMessage(_("Loading wallet…"));
+ context.chain->initMessage(_("Creating wallet…"));
std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), wallet_creation_flags, error, warnings);
if (!wallet) {
error = Untranslated("Wallet creation failed.") + Untranslated(" ") + error;
@@ -447,6 +447,7 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
}
}
+ WITH_LOCK(wallet->cs_wallet, wallet->LogStats());
NotifyWalletLoaded(context, wallet);
AddWallet(context, wallet);
wallet->postInitProcess();
@@ -3075,8 +3076,6 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
return nullptr;
}
- WITH_LOCK(walletInstance->cs_wallet, walletInstance->LogStats());
-
return walletInstance;
}
Why this scored 21/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.