Repository navigation
fix(sdk-coin-xlm): accept alphanumeric Stellar asset codes in StellarToken - #10109
Conversation
|
|
…Token StellarToken.tokenPattern only allowed uppercase letters in the asset code, so any token whose code contains a digit (e.g. xlm:USDM1, xlm:USDT0) failed to instantiate and threw `invalid token: ...`. That blocked explainTransaction and signTransaction in OVC for those tokens, leaving clients unable to move funds. The pattern was also unanchored, so it silently matched codes it should have rejected. Stellar asset codes are alphanumeric (a-z, A-Z, 0-9) and 1-12 characters long: see stellar-core `isAsciiAlphaNumeric`/`isAssetValid` and the AssetCode4 and AssetCode12 XDR definitions. Lowercase is legal and already onboarded (xlm:gBENJI-...), so the code class must not be uppercase-only. Anchor the pattern and accept [a-zA-Z0-9] in the asset code. Ticket: COINS-2284
a790b07 to
e2ef458
Compare
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
@claude please review this pr. |
|
Claude finished @nayandas190's task in 23s —— View job Review of #10109: accept alphanumeric Stellar asset codesVerdict: looks good to merge. I found no blocking issues.
Fix (
|
Summary
Fixes COINS-2284.
StellarTokenrejected every Stellar token whose asset code contains a digit, so MI Financial Services DAO LLC could not withdrawxlm:USDM1from its Go account: uploading the unsigned transaction to OVC failed inexplainTransaction.Root cause
modules/sdk-coin-xlm/src/stellarToken.tsvalidated the token in its constructor with:Two defects:
[A-Z], which excludes digits. Stellar asset codes arealphaNum4/alphaNum12, so digits are legal —USDM1andUSDT0both failed the match. Any call that instantiates the token (explainTransaction,signTransaction,bitgo.coin('xlm:USDM1-…')) threwBitGoJsError: invalid token: ….xlm:gBENJI-…andtxlm:yGHS-…passed despite their lowercase codes — the regex matchedBENJI-G…/GHS-G…. It also allowed trailing garbage after the issuer.Fix
Anchored, and
[a-zA-Z0-9]for the asset code, which matches the on-chain rule: stellar-core validates codes withisAsciiAlphaNumeric(a-z,A-Z,0-9) inisAssetValid, and theAssetCode4/AssetCode12XDR types are documented as "alphanumeric characters". Lowercase is legal and already onboarded (xlm:gBENJI-…,txlm:yGHS-…), so the code class must not be uppercase-only.Anchoring is safe for every token currently in
@bitgo/statics: with the corrected code class, all 35 registered XLM tokens match the anchored pattern.Tests
Added
describe('StellarToken:')tomodules/sdk-coin-xlm/test/unit/xlm.ts:@bitgo/staticsregisters and instantiates (coversUSDM1/USDT0and any future alphanumeric code);code/issuer;Verification on this branch:
Before the
stellarToken.tschange, 3 of the 4 new tests fail with the exact error from the ticket (BitGoJsError: invalid token: xlm:USDM1-GDM5QWWXCMDTQMZAKMYTCI52LA7FWBHAZMU5NJLMIFHDJISJRP2ZWPKC), confirming the regression is reproduced and fixed.eslint,prettier --checkandtsc --buildreport no errors in this module.Follow-up (not in this PR)
To unblock the client:
master;Publish @bitgo-betaworkflow (workflow_dispatchonmaster), which re-scopes and publishes@bitgo-beta/sdk-coin-xlm@2.0.5-beta.<next>;@bitgo-beta/sdk-coin-xlminoffline-vault-consoleand cut an OVC release.No
@bitgo-beta/staticsbump is needed: the token has been in statics sinceCOIN-7264and is already present in OVC v4.11.67. The blocker was the SDK's token validation, not missing token metadata — which is why a statics bump alone would not have fixed this.No wallet-platform bump is needed either: wallet-platform validates Stellar tokens against its own config pattern, which is already anchored and alphanumeric (
wallet-platform/config/env/defaults.ts:1563→/^[A-Za-z0-9]{1,12}-G[A-Z0-9]{55}$/), and it never instantiates the SDK'sStellarToken(it only importsUtilsfrom@bitgo-beta/sdk-coin-xlm). A repo-wide search ofbitgo-microservicesfinds no copy of the old uppercase-only pattern.