fix(wallet): validate network and genesis hash consistency - #520
Open
busayo-OD wants to merge 1 commit into
Open
fix(wallet): validate network and genesis hash consistency#520busayo-OD wants to merge 1 commit into
busayo-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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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