Skip to content

Large Batch Payment Operation Chunker #539

Description

@Kingsman-99

Description

Stellar transactions are limited to 100 operations each. When a split invoice has more recipients than that limit, the SDK crashes attempting to build an over-limit transaction rather than splitting it into multiple chained transactions. A chunker should automatically partition recipient operations into valid transaction batches, submit them in sequence, and report the batch results as a single logical invoice payment.

Technical Context

Add src/operationChunker.ts. Reads MAX_OPERATIONS_PER_TRANSACTION = 100 constant. Accepts OperationOptions[] from @stellar/stellar-sdk and partitions them into chunks. Each chunk is built via src/txBuilder.ts. Chunks are submitted in sequence using src/client.ts. All chunk hashes are recorded in BatchPaymentResult added to src/types.ts. Integrates with src/idempotency.ts to prevent duplicate chunk submission on retry.

Acceptance Criteria

  • OperationChunker.chunk(operations: OperationOptions[], chunkSize = 100): OperationOptions[][] partitions operations into sub-arrays of at most chunkSize
  • OperationChunker.submitAll(chunks, txBuilderConfig): Promise<BatchPaymentResult> submits each chunk sequentially and collects txHash per chunk
  • On partial failure (one chunk succeeds, the next fails), reports successful chunks in BatchPaymentResult.succeeded and the failed chunk in BatchPaymentResult.failed
  • Uses src/idempotency.ts idempotency keys per chunk to ensure a retry does not resubmit already-successful chunks
  • Unit tests with 150 and 250 recipients assert correct chunk counts (2 and 3 respectively) and that each chunk is within the operation limit
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions