wallet: Use CWallet::LoadExisting() for loading existing wallets.
What changed, and why it matters
This commit changes three internal wallet-loading call sites in Bitcoin Core to use a dedicated CWallet::LoadExisting() method instead of the more general CWallet::Create(). The change is a code-quality and correctness refactor: it makes it explicit that these paths are loading an already-existing wallet rather than creating a new one. There is no direct evidence in the commit that this fixes a security vulnerability, and the diff does not show any new input validation, bounds checks, or cryptographic changes.
Treat as a routine refactor. Review the implementation of CWallet::LoadExisting() in surrounding commits to confirm it does not introduce behavioral changes that could affect wallet creation flags or migration error handling. No immediate security response is indicated by this commit alone.
Security signals we found
No security-relevant keywords in commit title or message
No input validation, sanitization, or cryptographic changes visible
Refactor from generic Create() to semantically specific LoadExisting()
No referenced CVE, advisory, or security disclosure
Evidence from the diff
The patch replaces CWallet::Create(context, name, database, create_flags, error, warnings) with CWallet::LoadExisting(context, name, database, error, warnings) in LoadWallets(), LoadWalletInternal(), and MigrateLegacyToDescriptor(). The new LoadExisting() presumably omits creation-time logic and ignores create_flags. The diff itself is a simple rename substitution; it does not reveal what LoadExisting() does. Without the implementation of LoadExisting(), we cannot conclude it fixes a bug, but the change is consistent with a refactor to clarify intent and avoid accidental wallet creation during load/migration.
Changed components
src/wallet/load.cppsrc/wallet/wallet.cppBitcoin Core wallet loading and migration pathsInspect captured patch +3 / −3
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp
index f3620644..8d223466 100644
--- a/src/wallet/load.cpp
+++ b/src/wallet/load.cpp
@@ -147,7 +147,7 @@ bool LoadWallets(WalletContext& context)
}
}
chain.initMessage(_("Loading wallet…"));
- std::shared_ptr<CWallet> pwallet = database ? CWallet::Create(context, name, std::move(database), options.create_flags, error, warnings) : nullptr;
+ std::shared_ptr<CWallet> pwallet = database ? CWallet::LoadExisting(context, name, std::move(database), error, warnings) : nullptr;
if (!warnings.empty()) chain.initWarning(Join(warnings, Untranslated("\n")));
if (!pwallet) {
chain.initError(error);
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 44afd1cd..e5c21dc0 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -282,7 +282,7 @@ std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::s
}
context.chain->initMessage(_("Loading wallet…"));
- std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), options.create_flags, error, warnings);
+ std::shared_ptr<CWallet> wallet = CWallet::LoadExisting(context, name, std::move(database), error, warnings);
if (!wallet) {
error = Untranslated("Wallet loading failed.") + Untranslated(" ") + error;
status = DatabaseStatus::FAILED_LOAD;
@@ -4252,7 +4252,7 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
}
// Make the local wallet
- std::shared_ptr<CWallet> local_wallet = CWallet::Create(empty_context, wallet_name, std::move(database), options.create_flags, error, warnings);
+ std::shared_ptr<CWallet> local_wallet = CWallet::LoadExisting(empty_context, wallet_name, std::move(database), error, warnings);
if (!local_wallet) {
return util::Error{Untranslated("Wallet loading failed.") + Untranslated(" ") + error};
}
Why this scored 16/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.