Repository navigation
Conversation
The create command opened the new, empty database through PopulateWalletFromDB before it set the wallet flags and generated the descriptors. There is nothing to load at that point, and it made the loading code accept a database without a FLAGS record. Skip the load when creating, and write the version records in WalletCreate as CWallet::CreateNew does, since loading no longer writes them. Signed-off-by: Jan Kahmen <[email protected]>
LoadWalletFlags only checked for WALLET_FLAG_DESCRIPTORS when the database had a FLAGS record. A SQLite wallet file without that record was loaded with no flags set and then handled as a legacy wallet, which ends in an Assert: - with a legacy record, in SetupLegacyDataSPKM, because the database is not bdb_ro - otherwise in LoadActiveScriptPubKeyMan, because the descriptors flag is not set loadwallet aborts the node on such a file, and with the wallet in the load on startup list the node no longer starts. Do the check whether or not the record exists, so the file is rejected as a legacy wallet. Nothing loads a database without the record anymore now that the wallet tool does not load on create. The unit tests that load a hand written database write the flags first. Signed-off-by: Jan Kahmen <[email protected]>
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible places where named args for integral literals may be used (e.g.
2026-11-16 06:52:49 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

LoadWalletFlagschecks forWALLET_FLAG_DESCRIPTORSonly insideif (batch.Read(DBKeys::FLAGS, flags)). A SQLite wallet file without a FLAGS record is loaded with no flags set and then handled as a legacy wallet, which ends in anAssert:SetupLegacyDataSPKM,Assert(m_database->Format() == "bdb_ro" || m_database->Format() == "sqlite-mock")LoadActiveScriptPubKeyMan,Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS))loadwalleton such a file aborts the node. If the wallet is in the load on startup list, the node aborts on every start. The existing check for legacy records in a descriptor wallet (UNEXPECTED_LEGACY_ENTRY) does not catch this, because it also depends on the flag.The second commit does the check whether or not the record exists, so the file is rejected with the legacy wallet error.
The first commit is needed for that:
bitcoin-wallet createopened the new, empty database throughPopulateWalletFromDBbefore it wrote the flags, which is the case the comment "The FLAGS key is absent during wallet creation" refers to.CWallet::CreateNewdoes not load anymore, and now the tool does not either. It writes the version records itself, asCreateNewdoes.Behavior change: a wallet database without a FLAGS record no longer loads.
bitcoin-wallet createwrites the same set of records as before (compared by record type on a new wallet).Measurement: regtest, RelWithDebInfo, base a527a00, descriptor wallet made with
createwallet, then edited with sqlite3.wallet.cpp:3577cscriptrecord addedwallet.cpp:3404Tests: new case in
wallet_descriptor.pyfor both files; on master the node aborts in it. Three unit tests that load a hand written database now write the flags first. Passing locally:test_bitcoinandtest_runner.pywith the default list. Not run: fuzz targets, lint.Contributed by turingpoint.