mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 15:11:38 +00:00
wallet: Require the descriptors flag when the FLAGS record is missing #36887
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36887
Loading…
Reference in a new issue
No description provided.
Delete branch "wallet-load-missing-flags"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
a527a0077a, descriptor wallet made withcreatewallet, 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.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
Conflicts
Reviewers, 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.
func(x, /*named_arg=*/0)in C++, andfunc(x, named_arg=0)in Python):src/wallet/test/walletload_tests.cpp:WalletDescriptor(std::make_shared<DummyDescriptor>(unknown_desc), 0, 0, 0, 0)src/wallet/test/walletload_tests.cpp:WalletDescriptor(std::make_shared<DummyDescriptor>(desc), 0, 0, 0, 0)src/wallet/test/walletload_tests.cpp:WalletDescriptor(descriptor, 0, 0, 0, 0)2026-11-16 06:52:49
🔵 Suggestion · Missing
FLAGSproduces migration advice that cannot workFor a SQLite wallet missing
FLAGS, the new rejection recommendsmigratewallet, which instead says it is already a descriptor wallet; occurrence outside deliberately edited test files is unconfirmed.Location:
src/wallet/walletdb.cpp:470(head).Review coverage was incomplete.
Reviewed:
7af8fcd6fb5b· Review report · Previous reportspermalink