mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 09:11:37 +00:00
wallet, refactor: modularise wallet by extracting out legacy wallet migration #34909
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!34909
Loading…
Reference in a new issue
No description provided.
Delete branch "wallet-migration"
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?
I've been meaning to scratch this itch for quite some time. It has been noted
by many developers that the
wallet/wallet.cppfile is quite hard to reasonabout.
It is more than 4500 lines long currently and this patch is an attempt to
shortern it by around 800 lines by extracting out the wallet migration code into
a dedicated
wallet/migration.cppfile.The other benefits of this PR I see are that it moves the legacy wallet stuff
from the main wallet file that paves the way for it being descriptor specific
(as much as possible), and makes legacy wallet migration code a first-class
citizen in its own file.
I hope it makes it easier for everyone to go through the main wallet file.
This patchset should be reviewed with --color-moved=dimmed-zebra option.
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.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
WalletBatchwrite failures by achow101)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/migration.cpp:WalletDescriptor(std::move(descs.at(0)), creation_time, 0, 0, 0)(watch-only descriptors)src/wallet/migration.cpp:AddWalletDescriptor(w_desc, keys, "", false)src/wallet/migration.cpp:WalletDescriptor(std::move(descs.at(0)), creation_time, 0, 0, 0)(solvable descriptors)src/wallet/migration.cpp:AddWalletDescriptor(w_desc, keys, "", false)2026-11-23 09:54:33
Fixed two things:
Pushed an update where three more migration specific
CWalletmethods are extracted out.Rebased over master from 8723a4f to ecaef3d.
🚧 At least one of the CI tasks failed.
Task
Windows native, fuzz, VS: https://github.com/bitcoin/bitcoin/actions/runs/24783607828/job/72521322210LLM reason (✨ experimental): CI failed because the
spkm_migrationfuzz target hit a wallet database format assertion (m_database->Format() != "bdb_ro" && != "mock") inwallet::CWallet::SetupLegacyScriptPubKeyManand exited with code 1.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Force pushed to fix the CI failures because of incorrectly resolving conflicts during rebase due to the changes in this file of this PR.
Split the diff into multiple commits to aid review from 7b87334 to e9f50db.
🚧 At least one of the CI tasks failed.
Task
lint: https://github.com/bitcoin/bitcoin/actions/runs/24828329553/job/72670043902LLM reason (✨ experimental): CI failed because the
trailing_newlinelint check reported a missing trailing newline insrc/wallet/migration.h.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Fixed lint failure due to missing new line in wallet/migration.h.
Rebased over master to incorporate changes from #34544.
Rebased over master to incorporate changes from #34806.
Rebased over master to incorporate changes from #28333.
Concept ACK
I see you opened also #34910, wouldn't it make sense to add that commit here?
As a future consideration, have you thought about whether this structure could accommodate future migration types beyond legacy-to-descriptor, perhaps with a dedicated migration class? Curious if that's something worth exploring as a follow-up.
I had raised it separately because that change in itself seemed fine as well and I didn't want the changes of this PR to hold merging that PR. But given that #34910 has not been merged yet, I have cherry-picked that commit here and closed that PR now in favour of this one.
I believe the migration is more of a one-off event and the likelihood of adding other migration flows beyond legacy-to-descriptor is very low, so I don't think it's worth introducing a dedicated migration class at this stage.
Rebased over master to incorporate changes from #35414.
🚧 At least one of the CI tasks failed.
Task
iwyu: https://github.com/bitcoin/bitcoin/actions/runs/27554400650/job/81454235475LLM reason (✨ experimental): CI failed because IWYU reported a failure (“Failure generated from IWYU”) due to incorrect/missing
#includeordering/content insrc/bench/pool.cpp.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
The CI / iwyu (pull_request) failure is unrelated and should have been fixed post https://github.com/bitcoin/bitcoin/pull/35535.
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased over master to incorporate changes from PR #35266.
Force-pushed to emphasise in the commit messages that most of the commits should be reviewed with the --color-moved=dimmed-zebra git option.
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased over master to incorporate changes from #32489.
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased over master to incorporate changes from #35501.
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased over master to fix conflicts.
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased over master to incorporate changes from #35935.
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased over master to incorporate changes from #35436 and #34681.
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased over master to incorporate changes from #35752.
🔵 Suggestion ·
walletutil.hunnecessarily exposes the full chain interfaceThe reference-only settings declarations make
walletutil.hconsumers inheritinterfaces/chain.h; a forward declaration would avoid that dependency, although compile-time savings are unmeasured.Location:
src/wallet/walletutil.h:8(head).🔵 Suggestion ·
migration.cppandmigration.homit the moved code's license headersThe extracted files omit the copyright and MIT notices from
wallet.cppandwallet.h, contrary to the attribution requirement inCONTRIBUTING.md.Location:
src/wallet/migration.cpp:1(head).🔵 Suggestion ·
GetWalletPathdocumentation is restored in an unrelated commitThe utility extraction drops the
GetWalletPathcomment, leaving the following migration-API extraction with an unrelated documentation-only change towalletutil.h.Location: src/wallet/walletutil.h:85 (commit).
Review coverage was incomplete.
Reviewed:
9fd8e543b3ce· Review report · Previous reportspermalink
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased over master to incorporate changes from #32895.
Concept ACK
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased over master to incorporate changes from #36397.
I think it would be better if we could put all of the legacy wallet migration stuff into its own subdirectory, e.g.
src/wallet/legacy/rather than having the multiple migration related files in the main wallet module directory. This would let us separate out all of the migration things without polluting the main module with these files, especially as there are more things that can be pulled out (in future PRs) from database things.In
adfcde180e"wallet: (move-only) extract out migration specific CWallet methods"Could these functions be made non-members of CWallet? I don't really like having the implementation of member functions be spread across multiple files.
Yes, I did think of this initially but didn't do to keep the scope minimal, but will make them non-members of CWallet now.
ACK
60136a68baI've opened #36897 to implement the suggestions I made earlier, along with additional encapsulation.
In
f92202584e"wallet: extract out utility functions from wallet/wallet"This should be in the previous commit, surprised that CI is passing as the previous commit does not compile.
Will be able to check this after couple days.
What failure are you seeing?
adfcde180eseems to compile fine for me locally.cc @maflcko
I think it compiles, because the decl exists twice?
for me it compiles:
Probably fails because I always use
-DCMAKE_COMPILE_WARNING_AS_ERROR=ONAh, the CI and I use clang, which doesn't detect this.
🐙 This pull request conflicts with the target branch and needs rebase.
Done.
Rebased over master to fix conflicts with #36087.
ACK
9fd8e543b3review ACK
9fd8e543b3🥗Show signature
Signature:
#34193 😭. Painful rebase.