Skip to content

feat: add Stellar public key validation before Horizon calls#61

Open
Hovibby wants to merge 1 commit into
Sorokit:mainfrom
Hovibby:feat/public-key-validation
Open

feat: add Stellar public key validation before Horizon calls#61
Hovibby wants to merge 1 commit into
Sorokit:mainfrom
Hovibby:feat/public-key-validation

Conversation

@Hovibby

@Hovibby Hovibby commented Jun 24, 2026

Copy link
Copy Markdown

closes #3

  • Upgrade isValidPublicKey() to use StrKey.isValidEd25519PublicKey()
    for full format, length, and CRC-16 checksum validation
  • Add early-exit guard in getAccount() — invalid keys return
    ACCOUNT_FETCH_FAILED before any Horizon request is made
  • getBalances() and getAssetBalances() inherit validation via delegation
  • Add early-exit guard in streamAccount() — invalid key yields a single
    error result and ends the stream immediately
  • Expand isValidPublicKey tests from 3 to 13 cases
  • Fix placeholder G... test keys in account.test.ts

- Upgrade isValidPublicKey() in shared/utils.ts to use StrKey.isValidEd25519PublicKey()
  from @stellar/stellar-sdk for full format, length, and CRC-16 checksum validation
- Add early-exit guard in getAccount() - invalid keys return ACCOUNT_FETCH_FAILED
  with a descriptive message before any Horizon request is made
- getBalances() and getAssetBalances() inherit validation via getAccount() delegation
- Add early-exit guard in streamAccount() - invalid key yields a single error result
  and ends the stream immediately instead of failing on every poll tick
- Expand isValidPublicKey tests: 13 cases covering valid key, wrong prefix,
  too short/long, empty string, null, undefined, number, lowercase chars,
  invalid chars (0/1/8/9), corrupted checksum, whitespace, contract ID as public key
- Fix placeholder G... test keys in account.test.ts to valid Stellar public keys
@Just-Bamford

Copy link
Copy Markdown
Collaborator

@Hovibby kindly resolve the conflict. nice work..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add comprehensive input validation for account public keys across all account functions

2 participants