Skip to content

Add buildPaymentMemo and parsePaymentMemo helpers to memoBuilder #610

Description

@Kingsman-99

Description

src/memoBuilder.ts builds transaction memos but has no standardised helper for the specific memo format used on invoice payment transactions. Different callers construct the memo string ad-hoc, causing inconsistency in Horizon transaction history. This issue adds a single canonical builder.

Acceptance Criteria

  • buildPaymentMemo(invoiceId: string, opts?: { tranche?: number }): string exported from src/memoBuilder.ts
  • Output format: "split:{invoiceId}" base case; "split:{invoiceId}:t{tranche}" when tranche provided; truncated to 28 bytes (Stellar memo text limit) with no mid-character cut on UTF-8
  • parsePaymentMemo(memo: string): { invoiceId: string; tranche?: number } | null exported — returns null for non-split memos
  • Round-trip: parsePaymentMemo(buildPaymentMemo(id, opts)) returns the original inputs
  • Both exported from src/index.ts
  • Unit tests: base format, tranche format, 28-byte truncation, round-trip, non-split memo returns null

Context

  • Target files: src/memoBuilder.ts, src/index.ts
  • Stellar memo text limit is 28 bytes — use Buffer.byteLength(str, 'utf8') to measure

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions