Skip to content

TransactionPanel has no Stellar address format validation or balance check before submission #587

Description

@k-deejah

Problem

src/components/TransactionPanel.tsx canSubmit guard (line 24) only checks that dest is a non-empty string and amount is a positive number:

const canSubmit = isConnected && dest.trim() && amount.trim() && parseFloat(amount) > 0;

There is no Stellar address format validation. A Stellar public key must start with G, be exactly 56 characters, and pass a base32 checksum. Users can currently enter abc, 0x1234, or an Ethereum address and the form will submit it to the network, wasting fees and confusing users with an opaque network error.

Two more related problems: (1) there is no balance check — entering an amount that exceeds the user's XLM balance submits to the network and fails there, rather than showing a clear inline error before submission; (2) the amount field uses type="number" but has no max attribute, so there is no browser-level upper bound either.

Solution

  1. Add a Stellar address validator. Use the regex /^G[A-Z2-7]{55}$/ for a lightweight check, or import StrKey.isValidEd25519PublicKey from @stellar/stellar-sdk for full checksum validation.
  2. Show an inline error under the Destination Address Input when format is invalid.
  3. Compare parseFloat(amount) against the XLM balance from useSorokit() context and show an "Insufficient balance" error when exceeded.
  4. Keep canSubmit false while either validation fails.

Acceptance Criteria

  • Entering a non-G string in Destination shows an inline validation error
  • Entering a string shorter or longer than 56 characters shows an inline error
  • The Send button is disabled until the destination passes validation
  • Entering an amount above the XLM balance shows an "Insufficient balance" error
  • Valid addresses and amounts do not trigger false errors
  • Network submission is only attempted when all client-side checks pass

Note for Contributors: If you're assigned to this issue, write a clear and detailed description for your pull request. Explain what was changed, why it was needed, how it was implemented, and include any relevant testing or screenshots where applicable.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't workingfrontendUI, component, or visual layer concernsecuritySecurity, input validation, or data exposure

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions