Skip to content

Referral: user-chosen payout threshold above the system minimum#212

Merged
v0l merged 1 commit into
masterfrom
feat/referral-user-payout-threshold
Jul 24, 2026
Merged

Referral: user-chosen payout threshold above the system minimum#212
v0l merged 1 commit into
masterfrom
feat/referral-user-payout-threshold

Conversation

@v0l

@v0l v0l commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the on-chain referral payout work (#184). Referrers — on-chain ones especially — often don't want a stream of tiny payouts. This lets a referrer set a personal payout_threshold (in satoshis) so commission batches up to a larger amount before an automated payout is made.

Behaviour

  • New payout_threshold on POST/PATCH /api/v1/referral, returned on the Referral response and admin referral endpoints.
  • The value must be at least the system minimum for the payout method (Lightning uses min-payout-sats, on-chain uses min-onchain-payout-sats); the API rejects lower values.
  • Effective threshold at payout time is max(system minimum, payout_threshold) — a referrer can raise the bar but never lower it below the operator's floor.
  • null/omitted keeps the current behaviour (system minimum).
  • Admin can set it too (not bounded by the system minimum — operator override).

Changes

  • Migration adds nullable referral.payout_threshold; model + DB (mysql + mock) updated.
  • Payout worker applies effective_min_msat() in both the Lightning and on-chain (payable_onchain_msat) paths.
  • API validation (validate_payout_threshold / system_min_payout_sats) + request/response wiring.
  • Unit tests for effective_min_msat and validate_payout_threshold.
  • Docs + changelog; also corrected stale lightning_address/onchain_address docs to the merged single address field from feat(referral): on-chain payout mode, batched into a single send-many tx #208.

Referrers can set a personal payout_threshold (satoshis) so they batch
commission up to a larger amount and avoid many tiny payouts (on-chain in
particular). The value must be >= the system minimum for the payout mode
(API rejects lower); the effective threshold at payout time is
max(system_min, payout_threshold), so a referrer can only raise the bar.

- Add referral.payout_threshold column (migration) + model field.
- Payout worker uses effective_min_msat() in both the Lightning and
  on-chain paths.
- POST/PATCH /api/v1/referral accept + validate payout_threshold; it's
  returned on the Referral response and admin referral endpoints (admin
  override is not bounded by the system minimum).
- Unit tests for effective_min_msat and validate_payout_threshold.
- Docs + changelog; also corrected stale lightning_address/onchain_address
  docs to the merged single 'address' field.
@v0l
v0l enabled auto-merge July 24, 2026 10:51
@v0l
v0l merged commit b2230e1 into master Jul 24, 2026
8 checks passed
@v0l
v0l deleted the feat/referral-user-payout-threshold branch July 24, 2026 10:55
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.

1 participant