#34909 wallet, refactor: modularise wallet by extracting out legacy wallet migration
https://github.com/bitcoin/bitcoin/pull/34909 · · +864/-832 in 16 files, 5 commits · labels: none
Goal
- Make the core wallet code easier to navigate and maintain
- Separate legacy wallet migration logic out of the main wallet codebase
Extracts legacy wallet migration methods and public functions out of `wallet/wallet.cpp` into a dedicated `wallet/migration.cpp` unit. Also moves wallet settings helpers into `wallet/walletutil` and renames `wallet/migrate` to `wallet/legacybdb` to clarify its scope as Berkeley DB handling.
Problem: The main `wallet/wallet.cpp` file is over 4500 lines long and contains legacy migration logic mingled with core wallet functionality, making the file harder to navigate and maintain.
Category: Wallet (#50 of 84)
P3 · cleanup
- P3 because this is an internal cleanup with no user-facing behavioral changes
- Reduces the oversized core wallet file by separating legacy migration logic
- Aids long-term maintainability for wallet developers
P3 because this is a pure code organization refactor with no behavioral changes. It reduces the size of the 4500-line `wallet.cpp` by ~800 lines by separating legacy migration code into a dedicated module, aiding long-term maintainability.
Membership: Refactors wallet internals by extracting migration methods from CWallet and wallet.cpp to wallet/migration.cpp.
Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 1
Reviewability: Ready
- Ready to review with clean move-only diffs and passing CI
CI is passing, mergeable state is clean, commits are structured as move-only diffs, and the author actively rebases.
Author status: active
Resolved concerns:
- pablomartin4btc suggested incorporating the BDB file rename from #34910 directly into this PR, which the author did.
Agreement: Positive
- Positive sentiment with no objections
- Concept approval and suggested folding in related BDB file rename (pablomartin4btc)
Concept ACK with suggestion to include BDB file rename adopted (pablomartin4btc)
pablomartin4btc provided a Concept ACK and suggested folding in #34910, which the author did. There are no objections.
- pablomartin4btc: 'Concept ACK. I see you opened also #34910, wouldn't it make sense to add that commit here?'
Review verdicts (DrahtBot): 0
- Concept ACK: pablomartin4btc
Files
6 lines under test/bench/ci.
- src/wallet/wallet.cpp +0/-799
- src/wallet/migration.cpp +722/-0
- src/wallet/walletutil.cpp +89/-0
- src/wallet/migration.h +25/-0
- src/wallet/wallet.h +0/-25
- src/wallet/walletutil.h +15/-0
- src/wallet/{migrate.h => legacybdb.h} +3/-3
- src/wallet/CMakeLists.txt +2/-1
- src/wallet/{migrate.cpp => legacybdb.cpp} +1/-1
- src/wallet/test/db_tests.cpp +1/-1
- src/wallet/test/fuzz/wallet_bdb_parser.cpp +1/-1
- src/wallet/walletdb.cpp +1/-1
- src/bench/wallet_migration.cpp +1/-0
- src/wallet/interfaces.cpp +1/-0
- src/wallet/rpc/wallet.cpp +1/-0
- src/wallet/test/wallet_tests.cpp +1/-0
Card
Extracts around 800 lines of legacy wallet migration code and helpers out of wallet.cpp into wallet/migration.cpp and walletutil.cpp, and renames migrate.cpp to legacybdb.cpp. The change is move-only and aims to make wallet.cpp easier to reason about while isolating legacy Berkeley DB migration routines. It has a Concept ACK from pablomartin4btc, is cleanly rebased and passing CI, and has no open objections.