Skip to content

Add a CLI script to scaffold and publish a Stellar payment link from the terminal #32

Description

@MJ-RWA

Complexity: Medium — 150 pts

Summary

StellarFlow's payment link generator lives only inside the web UI. Developers and power users who want to generate a stellarflow.vercel.app/pay?... link programmatically — for use in scripts, bots, invoices, or CI pipelines — have no way to do it without opening the browser. This issue adds a lightweight Node.js CLI script (scripts/generate-link.mjs) that accepts address, amount, asset, and memo as arguments and outputs the full payment link to stdout.

Files to Create/Modify

  • Create: scripts/generate-link.mjs — the CLI script
  • Create: scripts/README.md — usage documentation
  • Create: scripts/generate-link.test.mjs — Node assert-based tests
  • Modify: package.json — add generate-link and test:scripts npm scripts

Implementation Notes

scripts/generate-link.mjs

Use Node's built-in node:util parseArgs to read --to, --amount, --asset (default XLM), --memo, --base (default https://stellarflow.vercel.app).

Validation, in order:

  1. --to and --amount are required → exit 1 with usage message if missing
  2. --to must pass StellarSdk.StrKey.isValidEd25519PublicKey() → exit 1 if invalid
  3. --amount must parse to a positive number → exit 1 if invalid
  4. --memo, if present, must be ≤ 28 bytes via Buffer.byteLength(memo, 'utf8') → exit 1 if too long

Build the URL with URLSearchParams({ to, amount, asset }), add memo if present, and console.log the final ${base}/pay?${params} string.

package.json

"scripts": {
  "generate-link": "node scripts/generate-link.mjs",
  "test:scripts": "node scripts/generate-link.test.mjs"
}

scripts/README.md

Document the usage, an options table (flag, type, default, description), and example commands for XLM, USDC with memo, and pointing at a local dev server via --base.

scripts/generate-link.test.mjs

Use Node's built-in assert and execSync to test: a basic XLM link includes the right params, a USDC+memo link includes asset=USDC and the memo, and an invalid address exits with status 1.

Acceptance Criteria

  • scripts/generate-link.mjs exists and is executable with Node.js (no build step required)
  • --to and --amount are required; script exits with code 1 and a clear message if missing
  • Invalid Stellar address (fails StrKey.isValidEd25519PublicKey) prints an error and exits with code 1
  • Memo longer than 28 bytes is rejected with a clear error
  • --base flag allows pointing at any StellarFlow deployment URL
  • npm run generate-link works as a convenience alias
  • scripts/README.md documents all flags with examples
  • npm run test:scripts runs all tests and passes

Screen Recording Requirements (terminal session)

  1. Run npm run generate-link -- --to GABCD... --amount 10 → valid URL printed to stdout
  2. Run with --asset USDC --memo "Invoice #42" → URL includes memo and asset params
  3. Open the printed URL in a browser → StellarFlow Pay page loads with the correct pre-filled values
  4. Run with an invalid Stellar address → clear error message printed, exit code 1
  5. Run npm run test:scripts → all tests pass

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions