Skip to content

fix(backend): correct off-by-one in isValidStellarAddress regex#1054

Open
Jah-yee wants to merge 1 commit into
LabsCrypt:mainfrom
Jah-yee:fix/1011-off-by-one-stellar-regex
Open

fix(backend): correct off-by-one in isValidStellarAddress regex#1054
Jah-yee wants to merge 1 commit into
LabsCrypt:mainfrom
Jah-yee:fix/1011-off-by-one-stellar-regex

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Jun 2, 2026

Summary

Fixes the off-by-one error in regex in .

The Bug

The regex only matches 55 characters total (G + 54 chars), but Stellar public keys are 56 characters (G + 55 chars). The preceding length check on line 33 correctly requires , so the regex was never able to match any valid address — the function was rejecting all valid Stellar addresses.

The Fix

Changed → in the regex, matching the implementation already used in and .

Verification

addr = 'GBUQWP3BOUZX34ULNQG23RQ6F4BVWCIBTLFL2F7HVRQG5LDHNWY2QTWA' // len 56
/^G[A-Z2-7]{54}$/.test(addr) === false  // was: always fail
/^G[A-Z2-7]{55}$/.test(addr) === true   // now: correct

Acceptance criteria (issue #1011)

  • Change the regex from {54} to {55}
  • Add a unit test asserting a real 56-char G... address returns true (already exists in at line 18)
  • Confirm assertValidStellarAddress no longer throws for valid input

Fixes #1011

Change {54} to {55} so the regex matches all 56 chars of a Stellar
public key (G + 55 base32 chars).

Fixes LabsCrypt#1011
@ogazboiz
Copy link
Copy Markdown
Contributor

ogazboiz commented Jun 3, 2026

your regex fix is correct, but the backend CI failure is on backend/src/app.ts:148 which is unrelated to your change — main itself has been red since #977 merged the /version endpoint with a line over prettier's printWidth. i opened #1055 to fix it. once that lands, please rebase and your CI will go green.

git fetch upstream
git rebase upstream/main
git push --force-with-lease

if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

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.

[Backend] Fix off-by-one regex in isValidStellarAddress that rejects valid 56-char addresses

2 participants