Skip to content

feat: add Claimable Balance support (conditional / time-locked payments)#61

Closed
nishant-uxs wants to merge 2 commits into
Stellar-Tools:mainfrom
nishant-uxs:feat/claimable-balances
Closed

feat: add Claimable Balance support (conditional / time-locked payments)#61
nishant-uxs wants to merge 2 commits into
Stellar-Tools:mainfrom
nishant-uxs:feat/claimable-balances

Conversation

@nishant-uxs

@nishant-uxs nishant-uxs commented Apr 25, 2026

Copy link
Copy Markdown
  • New lib/claimableBalance.ts module exposing createClaimableBalance, claimClaimableBalance, listClaimableBalances
  • Friendly tagged-union ClaimPredicate (unconditional / beforeRelativeTime / beforeAbsoluteTime / not / and / or) with input validation, depth guard, and amount/issuer checks
  • 1:1 claimant-to-operation mapping for deterministic balance ID extraction from result XDR
  • Wired into AgentClient as agent.claimable.{create,claim,list}
  • Public types exported from index.ts and agent.ts
  • 16 unit tests (vitest) covering predicate validation, input validation, signing, op shape, and Horizon list filters
  • README section with composable predicates table and end-to-end example

Motivates a key Stellar primitive missing from AgentKit, useful for AI-agent workflows: escrow, vesting, scheduled payouts, and conditional releases.


Summary by cubic

Adds claimable balance support for conditional and time-locked payments to enable escrow, vesting, and scheduled payouts. Exposes simple create, claim, and list APIs with composable predicates and deterministic balance ID extraction.

  • New Features

    • New lib/claimableBalance with createClaimableBalance, claimClaimableBalance, and listClaimableBalances.
    • Composable ClaimPredicate (unconditional, beforeRelativeTime, beforeAbsoluteTime, not, and, or) with validation and depth guard.
    • 1:1 claimant-to-operation mapping for deterministic balance ID extraction from result XDR.
    • Integrated into AgentClient as agent.claimable.{create,claim,list}; public types exported via agent.ts and index.ts.
    • README example and 16 unit tests.
  • Bug Fixes

    • Correct cap handling: limit to 100 operations per transaction; allow >10 claimants since each becomes its own balance. Exported MAX_CLAIMANTS_PER_BALANCE=10 as informational; tests and README updated.

Written for commit 87ecec8. Summary will update on new commits.

- New lib/claimableBalance.ts module exposing createClaimableBalance, claimClaimableBalance, listClaimableBalances
- Friendly tagged-union ClaimPredicate (unconditional / beforeRelativeTime / beforeAbsoluteTime / not / and / or) with input validation, depth guard, and amount/issuer checks
- 1:1 claimant-to-operation mapping for deterministic balance ID extraction from result XDR
- Wired into AgentClient as agent.claimable.{create,claim,list}
- Public types exported from index.ts and agent.ts
- 16 unit tests (vitest) covering predicate validation, input validation, signing, op shape, and Horizon list filters
- README section with composable predicates table and end-to-end example

Motivates a key Stellar primitive missing from AgentKit, useful for AI-agent
workflows: escrow, vesting, scheduled payouts, and conditional releases.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/claimableBalance.ts">

<violation number="1" location="lib/claimableBalance.ts:244">
P2: The function applies a per-balance 10-claimant protocol limit to the total number of one-claimant operations, incorrectly rejecting valid multi-balance requests.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/claimableBalance.ts Outdated
Address Cubic AI review (PR Stellar-Tools#61): the previous MAX_CLAIMANTS=10 check
incorrectly applied Stellar's per-balance protocol limit to the total number
of one-claimant operations, rejecting valid multi-balance requests.

Since createClaimableBalance emits one CreateClaimableBalance op per input
claimant (each resulting balance has exactly 1 claimant), the per-balance cap
does not apply. The effective limit is the per-transaction operation cap (100).

- Replace MAX_CLAIMANTS with MAX_OPERATIONS_PER_TRANSACTION=100
- Export MAX_CLAIMANTS_PER_BALANCE=10 as informational constant for future
  multi-claimant-per-balance support
- Update tests: assert >=11 claimants are accepted, only >100 rejected
- Update README to reflect the correct cap
@daiwikmh

Copy link
Copy Markdown
Contributor

values in files are constants.

@daiwikmh daiwikmh closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants