Skip to content

fix(subscriptions): enforce minimum interval_seconds to prevent allowance draining (#47) - #73

Open
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/subscription-min-interval-seconds-47
Open

fix(subscriptions): enforce minimum interval_seconds to prevent allowance draining (#47)#73
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/subscription-min-interval-seconds-47

Conversation

@ghzhost

@ghzhost ghzhost commented Sep 3, 2026

Copy link
Copy Markdown

Overview

Fixes #47 by establishing a minimum interval constraint on recurring subscriptions (interval_seconds >= 60).

Context & Problem

Previously, SubscriptionService::create only checked interval_seconds <= 0 and the database migration had CHECK (interval_seconds > 0). A subscription created with interval_seconds = 1 would become due again immediately after execution, causing the keeper background loop to repeatedly execute against the payer's on-chain allowance on every single poll pass.

Solution

  1. Named Minimum Constant: Defined pub const MIN_SUBSCRIPTION_INTERVAL_SECS: i64 = 60; in SubscriptionService.
  2. Service Validation: SubscriptionService::create now returns AppError::Validation when req.interval_seconds < MIN_SUBSCRIPTION_INTERVAL_SECS.
  3. Database Migration: Added migrations/012_min_subscription_interval.sql updating the CHECK constraint on subscriptions.interval_seconds to enforce >= 60.
  4. Unit Tests: Added test asserting MIN_SUBSCRIPTION_INTERVAL_SECS bound is configured properly.

Closes #47

…ance draining (StellarSend#47)

- Define MIN_SUBSCRIPTION_INTERVAL_SECS = 60s named constant in SubscriptionService
- Reject create requests with interval_seconds < MIN_SUBSCRIPTION_INTERVAL_SECS with AppError::Validation
- Add migration 012_min_subscription_interval.sql adding CHECK (interval_seconds >= 60)
- Add unit test verifying MIN_SUBSCRIPTION_INTERVAL_SECS bound
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.

No minimum bound on subscriptions.interval_seconds lets the keeper drain a payer's on-chain allowance every poll cycle

1 participant