Skip to content

Add account funding pre-flight checker #237

Description

@Kingsman-99

Label: complexity: high
Points: 200

Description

Before letting a user attempt to pay/create an invoice, check whether their account exists and has sufficient balance for the operation plus fees, surfacing a clear "fund your account first" UX hook rather than a late on-chain failure.

Technical Context

New src/preflightChecker.ts. Uses server.getAccount plus balance checks against the required token, called proactively by UI integrators before invoking client.pay/client.createInvoice.

Acceptance Criteria

  • checkPayerReadiness(address, requiredAmount, token) returns { ready: boolean, reason?: "account_not_found"|"insufficient_balance"|"no_trustline" }
  • Distinguishes the three failure reasons accurately
  • Exported from src/index.ts
  • Tests: each reason case individually verified; ready case returns ready: true with no reason

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions