Skip to content

Feat/creator self spending limit#250

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
Ajadu-Saviour:feat/creator-self-spending-limit
Jun 26, 2026
Merged

Feat/creator self spending limit#250
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
Ajadu-Saviour:feat/creator-self-spending-limit

Conversation

@Ajadu-Saviour

Copy link
Copy Markdown

Summary

Implemented creator self-imposed daily spending limits, allowing creators to voluntarily restrict their invoice creation spending while ensuring any increase to the limit is protected by the existing timelock mechanism.

What Changed

  • Added set_self_limit, request_raise_self_limit, get_self_limit, and get_self_limit_used functions.
  • Introduced storage for creator-specific limits, daily usage tracking, daily reset timestamps, and pending limit increase requests.
  • Extended the timelock system with a new RaiseCreatorSelfLimit action.
  • Updated invoice creation to enforce the effective spending limit using the lower of the admin-configured cap and the creator's self-imposed limit.
  • Implemented automatic daily usage resets and support for unlimited spending when the self-limit is set to 0.

Testing

Added comprehensive test coverage for:

  • Immediate limit reductions
  • Timelocked limit increases
  • Self-limit enforcement during invoice creation
  • Daily usage reset behavior
  • Unlimited (0) self-limit handling
  • Authorization requirements
  • Interaction between admin caps and creator self-limits

Result

Creators can now proactively control their own daily spending limits without affecting platform-wide policies. Immediate reductions improve account safety, while timelocked increases help prevent accidental or malicious limit changes, providing an additional layer of financial protection with comprehensive regression coverage.

Closes #229

Implements set_self_limit and request_raise_self_limit functions as per issue Stellar-split#241.

This feature allows creators to voluntarily self-restrict their spending
independent of admin-imposed caps. Key features:

- set_self_limit(creator, limit): Creator can immediately lower or set limit
  (requires creator auth)
- request_raise_self_limit(creator, new_limit): Request to raise limit via timelock
- Limit is enforced daily and resets at UTC midnight (86400s boundaries)
- Whichever is lower wins: admin cap or creator self limit
- Immediate raise attempts are blocked with clear error message

Implementation Details:
- Added RaiseCreatorSelfLimit to TimelockAction enum
- New storage keys for limit, daily usage, and last day marker
- Execute_action updated to handle self-limit raises after timelock
- Create_invoice enforces self-limit alongside admin caps
- Daily usage counter resets automatically at day boundary

Acceptance Criteria Met:
✓ set_self_limit requires creator auth, applies only to their address
✓ Lowering takes effect immediately
✓ Raising requires timelock + execute_action
✓ Invoice creation enforces self-limit (whichever is lower with admin cap)
✓ Comprehensive test coverage including:
  - Immediate lower works
  - Immediate raise blocked
  - Timelock raise succeeds
  - Enforcement in invoice creation
  - Daily reset behavior
  - Unlimited when set to 0
  - Auth requirement
  - Interaction with admin caps
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@Ajadu-Saviour 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

@Kingsman-99 Kingsman-99 merged commit 91010e3 into Stellar-split:main Jun 26, 2026
1 of 2 checks passed
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 invoice creator self-imposed spending limit

2 participants