Implement payments system with default free allowance and quota enforcement (#17)

* Initial plan for issue

* Implement complete payments system with quota enforcement

- Add default free allowance configuration (100MB)
- Implement quota checking before uploads in both blossom and nip96 routes
- Add comprehensive quota checking functions in database module
- Enhance admin API to show quota information
- Add payment processing infrastructure
- Include all necessary database migrations

Users now get 100MB free storage + any valid paid storage.
Uploads are rejected when quota would be exceeded.

* Move free_quota_bytes to PaymentConfig and restore mime_type parameter

Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
This commit is contained in:
Copilot
2025-06-10 11:37:17 +01:00
committed by GitHub
parent 71cb34eaee
commit ca2d23508b
15 changed files with 619 additions and 82 deletions

View File

@ -13,19 +13,39 @@ max_upload_bytes: 5e+9
# Public facing url
public_url: "http://localhost:8000"
# Whitelisted pubkeys, leave out to disable
# (Optional) Whitelisted pubkeys, leave out to disable
# whitelist: ["63fe6318dc58583cfe16810f86dd09e18bfd76aabc24a0081ce2856f330504ed"]
# Path for ViT(224) image model (https://huggingface.co/google/vit-base-patch16-224)
vit_model:
model: "/home/kieran/Downloads/falcon_nsfw.safetensors"
config: "/home/kieran/Downloads/falcon_nsfw.json"
# (Optional) Path for ViT(224) image model (https://huggingface.co/google/vit-base-patch16-224)
# vit_model:
# model: "falcon_nsfw.safetensors"
# config: "falcon_nsfw.json"
# Analytics support
# (Optional) Analytics support
# plausible_url: "https://plausible.com/"
# Support legacy void
# void_cat_database: "postgres://postgres:postgres@localhost:41911/void"
# (Optional) Legacy file path for void.cat uploads
# void_cat_files: "/my/void.cat/data"
# Legacy file path for void.cat uploads
# void_cat_files: "/my/void.cat/data"
# (Optional) Payment system config
payments:
# (Optional) Free quota in bytes for users without payments (default: 100MB)
free_quota_bytes: 104857600
# (Optional) Fiat currency used to track exchange rate along with invoices
# If [cost] is using a fiat currency, exchange rates will always be stored
# in that currency, so this config is not needed
fiat: "USD"
# LND node config
lnd:
endpoint: "https://127.0.0.1:10001"
tls: "/home/kieran/.polar/networks/3/volumes/lnd/alice/tls.cert"
macaroon: "/home/kieran/.polar/networks/3/volumes/lnd/alice/data/chain/bitcoin/regtest/admin.macaroon"
# Cost per unit (BTC/USD/EUR/AUD/CAD/JPY/GBP)
cost:
currency: "BTC"
amount: 0.00000100
# Unit metric used to calculate quote (GBSpace, GBEgress)
unit: "GBSpace"
# Billing interval (day / month / year)
interval:
month: 1