PopulateWalletFromDB() and improves documentation for LoadExisting() and CreateNew(), and makes WalletBatch::WriteVersion(int client_version) respect the argument that it’s passed, addressing issues reviewers pointed in #32636.
PopulateWalletFromDB() and improves documentation for LoadExisting() and CreateNew(), and makes WalletBatch::WriteVersion(int client_version) respect the argument that it’s passed, addressing issues reviewers pointed in #32636.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
See the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.
No conflicts as of last run.
Possible typos and grammar issues:
std::nullptr -> nullptr [std::nullptr is not valid; the correct null pointer literal is nullptr. This appears in two added docs (“CreateNew” and “LoadExisting”).]2026-02-04 21:40:44
This addresses review comments from #32636:
- https://github.com/bitcoin/bitcoin/pull/32636#discussion_r2755916371
- https://github.com/bitcoin/bitcoin/pull/32636#discussion_r2756024581,
- https://github.com/bitcoin/bitcoin/pull/32636#discussion_r2756055872
https://github.com/bitcoin/bitcoin/pull/32636#discussion_r2756245482
Previously would use global `CLIENT_VERSION` no matter what, but this is
one sense a refactor since all of the places where WriteVersion is
called currently call it with `CLIENT_VERSION` anyways. The
`client_version` argument is kept since future test code may want to
write other versions.
Addresses a review comment from #32636:
https://github.com/bitcoin/bitcoin/pull/32636#discussion_r2356299627
Now that #32636 is merged this can be reviewed.
(soft ping @murchandamus, @enirox001, and @rkrux whose review comments are addressed in this PR)
796@@ -797,6 +797,19 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
797 bool IsFromMe(const CTransaction& tx) const;
798 CAmount GetDebit(const CTransaction& tx) const;
799
800+ /**
801+ * Pass-through to WalletBatch::LoadWallet() to initialize this CWallet from
802+ * the records stored in CWallet::m_database. Primarily used by
803+ * CWallet::LoadExisting.
4303@@ -4304,7 +4304,7 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
4304 return util::Error{Untranslated("Wallet file verification failed.") + Untranslated(" ") + error};
4305 }
4306
4307- // Make the local wallet
4308+ // Initialize the CWallet for the local wallet.
Is any comment required here now?
The older comment might have been needed when CWallet::Create was called wherein it was not obvious in the caller whether the wallet would be created or loaded.
Reading CWallet::LoadExisting below seems pretty self explanatory to me.
264@@ -265,8 +265,14 @@ class WalletBatch
265
266 DBErrors LoadWallet(CWallet* pwallet);
267
268- //! Write the given client_version.
269- bool WriteVersion(int client_version) { return m_batch->Write(DBKeys::VERSION, CLIENT_VERSION); }
270+ /**
271+ * Write the given `client_version` to #m_batch, indicating the last version
#m_batch
Typo?
885@@ -873,10 +886,24 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
886
887 static bool LoadWalletArgs(std::shared_ptr<CWallet> wallet, const WalletContext& context, bilingual_str& error, std::vector<bilingual_str>& warnings);
888
889- /* Initializes, creates and returns a new CWallet; returns a null pointer in case of an error */
890+ /**
891+ * Create a new wallet.
davidgumberg
DrahtBot
murchandamus
rkrux
w0xlt
Labels
Wallet