Skip to content

Account Freeze and Lock State Detector #532

Description

@Kingsman-99

Description

A Stellar account can be prevented from transacting by an issuer revoking authorisation (freeze) or by being flagged AUTH_IMMUTABLE in a state that prevents future authorisation. Sending payments to or from such accounts results in submission failures that are difficult to distinguish from other errors. A detector should identify accounts in a frozen or effectively locked state before any payment operation is attempted.

Technical Context

Add src/accountStateDetector.ts. Reads TrustLineRecord.authorized and TrustLineRecord.authorized_to_maintain_liabilities from @stellar/stellar-sdk Server.loadAccount(). Inspects AccountRecord.flags.auth_revocable and auth_immutable. Integrates with src/preflightChecker.ts. Adds AccountLockState to src/types.ts. Throws AccountFrozenError or AccountLockedError from src/errors.ts as appropriate.

Acceptance Criteria

  • detectLockState(accountId: string, asset: Asset): Promise<AccountLockState> returns { isFrozen, isLocked, trustlineAuthorized, reason? }
  • Detects frozen trustline by checking authorized: false and authorized_to_maintain_liabilities: false on the matching trustline
  • Detects issuer-side AUTH_REVOCABLE flag that would allow future revocation and includes it in the report as { revocableByIssuer: true }
  • src/preflightChecker.ts calls detectLockState() for each recipient and blocks payment if any account is frozen
  • Unit tests mock account records for: fully authorized, frozen (authorized: false), and locked (immutable) scenarios
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions