mirror of
https://github.com/Such-Software/smirk-backend-core.git
synced 2026-12-04 22:44:13 +01:00
feat(registration): pay-to-register via pluggable payment provider (gate #3)
Optional REGISTRATION_REQUIRE_PAYMENT gate: a new wallet must settle an invoice on an external, non-custodial payment processor before it can register. Pull model — the grant reads the processor's authenticated API as the source of truth, so there is no inbound webhook to secure and a settled invoice cannot be forged over HTTP. Returning wallets and self-hosting bypass it, exactly like the invite and PoW gates. - infra/payment: a pluggable PaymentProvider seam (neutral Invoice / InvoiceStatus / InvoiceRequest) with a BTCPay-compatible first adapter that also serves this project's xmrcheckout/wowcheckout apps + the BTCPay Monero plugin, so "operator picks any coin" costs one adapter. A future ETH/native adapter (BTCPay serves neither) implements the same trait. Only `Settled` grants (unknown status fails safe); the API key rides in a redacting Secret and hostile responses are size-capped. - payment_invoices: invoice<->pubkey_hash binding + atomic single-use consume (UPDATE ... WHERE consumed_at IS NULL AND pubkey_hash=$ RETURNING), so one invoice grants at most one registration and never a different identity. - POST /auth/payment-invoice mints + binds; enforce_payment (bind -> processor `Settled` -> atomic consume) runs beside enforce_invite; payment_invoice_id on the register request. - Fail-closed config: https-in-prod, positive-decimal price, >= 1 confirmation (bars a 0-conf settled-then-double-spent free registration), bounded expiry. /capabilities advertises payment_required + price; OpenAPI + .env.example. Tests: adapter status/speedPolicy mapping + config validation (unit), and L1 binding + atomic single-use (concurrent-consume-one-wins, mis-bind rejected). Reviewed adversarially across payment-integrity, leak/oracle, and config/DoS lenses; the confirmed findings (0-conf, expiry bound, Settled-means-paid-in-full adapter contract, rotation-branch bypass guard) are addressed here.
This commit is contained in:
+23
-1
@@ -31,9 +31,31 @@ ALTCHA_COST=100000
|
||||
# Require an operator-minted invite code to create a NEW wallet. Mint codes with
|
||||
# `smirk-admin mint-invite --count <n>`. Returning wallets bypass it, and
|
||||
# self-hosting bypasses all gates (run your own backend). PoW is the ALTCHA gate
|
||||
# above; pay-to-register is planned. Compose freely (e.g. invite + PoW).
|
||||
# above. Compose freely (e.g. invite + PoW + pay-to-register).
|
||||
REGISTRATION_REQUIRE_INVITE=false
|
||||
|
||||
# Pay-to-register: require a SETTLED payment invoice to create a new wallet. The
|
||||
# invoice is minted at POST /auth/payment-invoice and paid — directly to YOUR own
|
||||
# wallet — via an external, non-custodial processor. The `btcpay` adapter speaks
|
||||
# the BTCPay-compatible invoice API, which also covers this project's xmrcheckout
|
||||
# /wowcheckout apps and the BTCPay Monero plugin, so you pick the coin by pointing
|
||||
# at the processor that accepts it. The backend only READS invoice status (pull
|
||||
# model) — it never holds funds or keys. Self-hosting bypasses this (leave off).
|
||||
REGISTRATION_REQUIRE_PAYMENT=false
|
||||
PAYMENT_PROVIDER=btcpay
|
||||
# Processor base URL, store/merchant id, and an API key that can create + read
|
||||
# invoices (held redacted; never logged). Required when the gate is on.
|
||||
PAYMENT_PROVIDER_URL=https://pay.example.org
|
||||
PAYMENT_STORE_ID=
|
||||
PAYMENT_API_KEY=
|
||||
# Registration price + currency ('XMR', or a fiat code the processor converts).
|
||||
PAYMENT_AMOUNT=0.01
|
||||
PAYMENT_CURRENCY=XMR
|
||||
# Confirmations-to-finalize (mapped to the processor's speed policy), and how long
|
||||
# an unpaid invoice stays payable before it expires.
|
||||
PAYMENT_CONFIRMATIONS=1
|
||||
PAYMENT_EXPIRES_MINUTES=60
|
||||
|
||||
# ── Bitcoin ───────────────────────────────────────────────────────────────
|
||||
BTC_NETWORK=mainnet
|
||||
BTC_USE_LOCAL_NODE=false
|
||||
|
||||
Reference in New Issue
Block a user