-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: HD chain encryption check ordering issue #6944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Previously, LoadHDChain() would fail if CRYPTED_HDCHAIN records were read before MASTER_KEY records during wallet loading, because the check `m_storage.HasEncryptionKeys() != chain.IsCrypted()` would incorrectly fail when mapMasterKeys was still empty. This commit fixes the issue by: - Adding an optional fSkipEncryptionCheck parameter to LoadHDChain() - Skipping the encryption check during wallet loading in ReadKeyValue() - Adding comprehensive validation in LoadWallet() after all records are loaded to ensure HD chain encryption consistency This preserves the safety check for encryption operations while allowing wallet loading to succeed regardless of database record ordering. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
WalkthroughThe changes refactor HD chain loading validation timing by introducing a Sequence DiagramsequenceDiagram
participant LoadWallet
participant LoadHDChain
participant HDChainValidation
LoadWallet->>LoadHDChain: LoadHDChain(chain, skip_encryption_check=true)
Note over LoadHDChain: Skips encryption consistency check
LoadHDChain-->>LoadWallet: Return true
Note over LoadWallet: Complete wallet data loading...
rect rgb(230, 245, 250)
Note over LoadWallet: Post-load validation phase
LoadWallet->>HDChainValidation: Check encryption state<br/>storage.HasEncryptionKeys() vs<br/>chain.IsCrypted()
alt Mismatch detected
HDChainValidation-->>LoadWallet: Return CORRUPT
else State consistent
HDChainValidation-->>LoadWallet: Proceed normally
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (1)src/**/*.{cpp,h,cc,cxx,hpp}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (3)📓 Common learnings📚 Learning: 2025-08-08T07:01:47.332ZApplied to files:
📚 Learning: 2025-02-14T15:19:17.218ZApplied to files:
🧬 Code graph analysis (2)src/wallet/scriptpubkeyman.h (1)
src/wallet/walletdb.cpp (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Issue being fixed or feature implemented
Previously, LoadHDChain() would fail if CRYPTED_HDCHAIN records were
read before MASTER_KEY records during wallet loading, because the
check
m_storage.HasEncryptionKeys() != chain.IsCrypted()wouldincorrectly fail when mapMasterKeys was still empty.
This PR fixes the issue by:
are loaded to ensure HD chain encryption consistency
What was done?
How Has This Been Tested?
run tests
Breaking Changes
n/a
Checklist: