Phase 2: money
Lightning payments through LNbits, wallets, passes, credits, the entitlement resolver and priority lanes. - internal/entitle: pure resolver (one-off, own pass, group pass, group credits, own credits, free) with a table-driven suite and an invariant check over every input combination - internal/billing: wallets, append-only ledger with dedupe keys, stacking passes, purchases, gift codes, referral reward - LNbits client verified against v0.12.12 and v1.7.1 source - Settlement by one conditional UPDATE: idempotent under any mix of webhooks, polls and the check button. Webhooks are unsigned, so every payment is confirmed with LNbits before it is credited - Polling fallback, reconciliation of all unsettled invoices at startup, late payments still honored, no expiry while LNbits is unreachable - Charge, quota and job are written in one transaction; failed, cancelled and undeliverable downloads are refunded exactly once - Paid lane first with one slot of the fleet reserved for free users - Daily download quota and daily volume cap, per-user and per-group rate limits - Bot: /buy /account /limits /credits /redeem /referral /donate, QR invoice message that flips to paid, over-limit offer (passes or this file only), deep links from groups, skip the queue - Fake LNbits server for tests; end-to-end money flows including a payment made while the core was down Cashu redemption is behind an interface and not implemented. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
3b361c17a1
commit
0d50f453a0
@@ -22,6 +22,11 @@ TELEGRAM_UPDATE_WORKERS=8
|
||||
# Telegram user IDs allowed to use owner commands, comma separated.
|
||||
OWNER_IDS=
|
||||
|
||||
# Public HTTPS base URL of this server, without a trailing slash. Used for
|
||||
# payment webhooks, "open in wallet" links and the Mini App. Payments work
|
||||
# without it (invoices are then settled by polling only).
|
||||
PUBLIC_URL=
|
||||
|
||||
# --- HTTP -------------------------------------------------------------------
|
||||
# Listen address of the health endpoint and the webhook.
|
||||
HTTP_LISTEN=:8080
|
||||
@@ -65,6 +70,53 @@ QUEUE_MAX_ATTEMPTS=2
|
||||
FREE_MAX_SIZE_MB=50
|
||||
FREE_MAX_DURATION=10m
|
||||
FREE_ACTIVE_JOBS=1
|
||||
# Per UTC day. 0 means no cap.
|
||||
FREE_DAILY_DOWNLOADS=5
|
||||
FREE_DAILY_MB=250
|
||||
|
||||
# --- Paid limits (passes, credits, one-off payments) ------------------------
|
||||
# Sizes above TELEGRAM_MAX_UPLOAD_MB need a local Bot API server.
|
||||
PAID_MAX_SIZE_MB=2000
|
||||
PAID_MAX_DURATION=3h
|
||||
PAID_ACTIVE_JOBS=3
|
||||
PAID_DAILY_DOWNLOADS=100
|
||||
# The daily volume cap applies to paying users too.
|
||||
PAID_DAILY_MB=20000
|
||||
|
||||
# --- Payments (LNbits) ------------------------------------------------------
|
||||
# Leave LNBITS_URL and LNBITS_INVOICE_KEY empty to run without payments.
|
||||
LNBITS_URL=
|
||||
# The wallet's INVOICE key (read only). Never give the bot the admin key.
|
||||
LNBITS_INVOICE_KEY=
|
||||
# Random string. It becomes part of the webhook path that LNbits calls:
|
||||
# <PUBLIC_URL>/lnbits/webhook/<LNBITS_WEBHOOK_SECRET>
|
||||
LNBITS_WEBHOOK_SECRET=
|
||||
# How often unsettled invoices are checked, as a fallback for lost webhooks.
|
||||
LNBITS_POLL_INTERVAL=5s
|
||||
# How long an invoice can be paid.
|
||||
INVOICE_EXPIRY=10m
|
||||
|
||||
# --- Prices in sats ---------------------------------------------------------
|
||||
PRICE_PASS_DAY=700
|
||||
PRICE_PASS_WEEK=3000
|
||||
PRICE_PASS_MONTH=9000
|
||||
# Cost of one download when credits pay.
|
||||
PRICE_CREDIT_DOWNLOAD=50
|
||||
# "Pay for this file only": base plus a step per started 100 MB.
|
||||
PRICE_ONE_OFF_BASE=100
|
||||
PRICE_ONE_OFF_PER_100MB=50
|
||||
# Moving one waiting free job to the priority lane.
|
||||
PRICE_SKIP_QUEUE=50
|
||||
# Top-up and tip amounts offered as buttons.
|
||||
CREDIT_PACKS=1000,5000,20000
|
||||
DONATION_AMOUNTS=500,2100,10000
|
||||
# Credited to the inviter on an invited user's first purchase. 0 turns it off.
|
||||
REFERRAL_REWARD=200
|
||||
|
||||
# --- Rate limits ------------------------------------------------------------
|
||||
# Links per minute. 0 means no limit.
|
||||
RATE_USER_PER_MINUTE=10
|
||||
RATE_GROUP_PER_MINUTE=30
|
||||
|
||||
# --- Logging ----------------------------------------------------------------
|
||||
# debug, info, warn or error.
|
||||
|
||||
Reference in New Issue
Block a user