fix(wallet): validate network and genesis hash consistency - #520
fix(wallet): validate network and genesis hash consistency#520busayo-OD wants to merge 1 commit into
Conversation
Reject wallets configured for Network::Bitcoin with a non-mainnet genesis hash during wallet creation and loading. Introduce dedicated error variants to report these validation failures through the existing create and load APIs, and add regression tests covering both entry points. Signed-off-by: busayo-OD <toyinoluwabusayo@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #520 +/- ##
==========================================
- Coverage 81.84% 81.81% -0.03%
==========================================
Files 25 25
Lines 6487 6510 +23
Branches 296 300 +4
==========================================
+ Hits 5309 5326 +17
- Misses 1078 1081 +3
- Partials 100 103 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
It's curious why This might expand the scope somewhat but I'd suggest having a Also just noting it might help to wait until #524 is in since it also affects the wallet constructor methods. |
Fixes #46
Description
Previously,
Wallet::create_with_paramsandWallet::load_with_paramsallowedNetwork::Bitcointo be paired with a non-mainnet genesis hash, creating an internally inconsistent wallet configuration.This PR adds validation to both entry points:
Wallet::create_with_paramsreturnsDescriptorError::GenesisHashMismatchwhen a mainnet wallet is configured with a non-mainnet genesis hash.Wallet::load_with_paramsreturnsLoadError::GenesisNetworkMismatchwhen persisted wallet metadata contains the same inconsistency.Regression tests have been added for both code paths.
Notes to the reviewers
This PR revisits the earlier implementation attempt (#1777) and implements the approach that emerged from the review discussion:
Network::Bitcoin;To report these validation failures without changing the existing API signatures, this PR introduces
DescriptorError::GenesisHashMismatchandLoadError::GenesisNetworkMismatch.Changelog notice
Checklists
All Submissions
just pbefore pushingBugfixes