Split wallet.cpp: extract key management into wallet_keys.cpp

Separate key management from transaction logic in wallet.cpp (5,059 lines):
- wallet.cpp: 5,059 → 4,143 lines (transaction tracking, coin selection, balances)
- wallet_keys.cpp: 975 lines (key generation, encryption, HD seed, keypool)

Extracted functions include key generation (GenerateNewKey, GenerateNewSaplingZKey),
cryptographic key storage (AddKeyPubKey, AddCryptedKey, AddCryptedSaplingSpendingKey),
wallet encryption (Unlock, ChangeWalletPassphrase, EncryptWallet), HD seed management,
keypool operations, CReserveKey methods, and shielded key visitor operators.
This commit is contained in:
dan_s
2026-02-27 01:41:04 -06:00
parent 0083cd26bb
commit f565b2920d
4 changed files with 985 additions and 918 deletions

View File

@@ -35,7 +35,12 @@ Several files are extremely large and would benefit from decomposition:
| `src/chainparams.cpp` | 5,420 | Extract checkpoint data and chain-specific params to separate files |
| `src/wallet/wallet.cpp` | 5,059 | Split wallet transaction logic from key management |
- [ ] Split `src/main.cpp`
- [x] Split `src/main.cpp`
- 8,217 → 2,821 lines in `main.cpp`
- Created `tx_validation.cpp` (1,012 lines) — transaction validation (IsStandardTx, CheckTransaction, ContextualCheckInputs, etc.)
- Created `mempool_accept.cpp` (524 lines) — mempool acceptance and orphan management (AcceptToMemoryPool, AddOrphanTx, etc.)
- Created `block_processing.cpp` (4,064 lines) — block processing, chain management, and disk I/O (ConnectBlock, DisconnectBlock, ActivateBestChain, CheckBlock, LoadBlockIndex, etc.)
- Created `main_internal.h` (83 lines) — shared internal state (block index candidates, file info, dirty sets, etc.)
- [x] Split `src/wallet/rpcwallet.cpp`
- 6,392 → 4,099 lines in `rpcwallet.cpp`
- Created `wallet/rpcwallet_zindex.cpp` (1,193 lines) — z-index query RPCs (`getalldata`, `z_getinfo`, `z_getstats`, etc.)
@@ -45,7 +50,9 @@ Several files are extremely large and would benefit from decomposition:
- 5,420 → 593 lines in `chainparams.cpp`
- Created `chainparams_checkpoints_hush3.h` (1,986 lines) — HUSH3 checkpoint data
- Created `chainparams_checkpoints_dragonx.h` (2,853 lines) — DRAGONX checkpoint data
- [ ] Split `src/wallet/wallet.cpp`
- [x] Split `src/wallet/wallet.cpp`
- 5,059 → 4,143 lines in `wallet.cpp`
- Created `wallet_keys.cpp` (975 lines) — key management, encryption, HD seed, keypool
## 5. Move Implementation Out of Header Files