feat: Add Stellar address validation utility - #114
Merged
Jaydbrown merged 4 commits intoJun 24, 2026
Conversation
AbelOsaretin
commented
Jun 24, 2026
Contributor
Author
There was a problem hiding this comment.
1. CI Status ⚠️
- Analyze step fails — This is a pre-existing issue caused by
--fatal-infosflag in CI workflow - PR #104 already addresses this by changing to
--fatal-warnings - My code changes do not introduce new analysis errors
2. Merge Conflicts ✅
- No merge conflicts detected
- Add Validation class with stellarSecretKey and stellarPublicKey methods - Validate key format: prefix, length, and base32 character set - Return null for valid keys, error message string for invalid ones
- Integrate Validation.stellarSecretKey in _onConnect method - Show SnackBar with error message for invalid keys - Prevent invalid keys from being passed to WalletProvider.connect()
AbelOsaretin
force-pushed
the
feat/stellar-address-validation
branch
from
June 24, 2026 13:09
fe4a22e to
64d1105
Compare
- Test valid secret key format (prefix, length, base32 chars) - Test valid public key format - Test edge cases: empty string, wrong prefix, wrong length, invalid chars - Test trimming of whitespace in input
AbelOsaretin
force-pushed
the
feat/stellar-address-validation
branch
from
June 24, 2026 13:17
9584778 to
d297e4c
Compare
- S-key test fixture was 55 chars, now 56 chars - G-key test fixture was 59 chars, now 56 chars - Both test keys now match the 56-character requirement for Stellar keys
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.
Closes #82
Type of Change
Summary
The wallet connection flow accepted any non-empty string as a secret key, deferring validation to the Stellar SDK deep in the SEP-10 flow. This caused cryptic errors ("Invalid seed") instead of clear user-facing messages. This PR adds a
Validationutility class that validates Stellar secret and public key format at the UI boundary, showing immediate feedback for invalid inputs.Motivation / Context
Fixes #82
Users who mistype their secret key receive cryptic errors from the Stellar SDK instead of clear validation messages. The issue identifies that:
lib/utils/validation.dartreturns 404)Detailed Changes
New file:
lib/utils/validation.dart— AddedValidationclass with:stellarSecretKey(String key)— validates prefix 'S', length 56, base32 character setstellarPublicKey(String key)— validates prefix 'G', length 56nullfor valid keys, error message string for invalid onesModified:
lib/screens/wallet_screen.dart— Updated_onConnectmethod to:Validation.stellarSecretKey()before passing key to providerWalletProvider.connect()New file:
test/utils/validation_test.dart— Comprehensive unit tests covering:Current Behavior vs. New Behavior
Before: Enter any non-empty string → key passed to SDK → cryptic "Invalid seed" error deep in SEP-10 flow
After: Enter invalid key → immediate SnackBar with clear error message (e.g., "Secret key must start with 'S'", "Secret key must be exactly 56 characters (got 55)")
Testing
Screenshots / Recordings
N/A (CLI input validation)
Breaking Changes
No
Risks and Rollback
Low risk — validation is additive and non-breaking. Rollback: revert commits on the feature branch.
Checklist
Self-Review
console.log,print,debugger, commented-out blocks)Testing
CI / Pipeline
Documentation
Changelog
Security
Performance
Reviewer Notes
Additional References