Skip to content

Subscription: optional end ledger (subscribe_until) - #139

Merged
deeejaymu-afk merged 1 commit into
stellar-sub:mainfrom
edwina105:fix/drips-edwina105-52
Oct 22, 2026
Merged

deeejaymu-afk merged 1 commit into
stellar-sub:mainfrom
edwina105:fix/drips-edwina105-52

Conversation

@edwina105

Copy link
Copy Markdown
Contributor

Subscription: optional end ledger (subscribe_until)

Adds subscribe_until, which takes an end ledger, next to the unchanged subscribe, so no caller breaks.

  • Subscription gains expires_at (0 means no end).
  • No charge is allowed after that ledger. charge returns SubscriptionExpired and is_chargeable returns false, so the end only narrows what the merchant may do.
  • An end ledger that is not after the current ledger is refused with InvalidExpiry.
  • subscribe and subscribe_until share one creation path.
  • Tests cover charging up to and including the end ledger, refusal after it with state unchanged, invalid end ledgers, and a plain subscription having no end.

Closes #52

The issue was marked "Needs design" and asked for maintainer agreement first. This PR implements it at the contributor's request, using the subscribe_until option from the design proposal. Maintainers may prefer to change subscribe instead. The Subscription layout changes, so subscriptions stored by an earlier version lack the new field.

The code has not been compiled or run. Please check it in CI.

🤖 Generated with Claude Code

stellar-sub#52)

Add subscribe_until, which takes an end ledger, next to the unchanged
subscribe so no caller breaks. Subscription gains an expires_at field, where
0 means no end. No charge is allowed after that ledger: charge returns
SubscriptionExpired, and is_chargeable returns false, so the end only narrows
what the merchant may do. An end ledger that is not after the current ledger
is refused with InvalidExpiry. subscribe and subscribe_until share one
creation path. Tests cover charging up to and including the end ledger,
refusal after it with state unchanged, invalid end ledgers, and a plain
subscription having no end.

The Subscription layout changes, so subscriptions stored by an earlier
version do not have the new field.

Closes stellar-sub#52

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

@edwina105 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@deeejaymu-afk
deeejaymu-afk merged commit 8b47ca5 into stellar-sub:main Oct 22, 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.

Add an optional end ledger after which a subscription can never be charged

2 participants