Skip to content

Instantly share code, notes, and snippets.

@adrienemery
adrienemery / lightning_api.py
Last active October 26, 2019 07:34
LND "PayPI" (charge for api using lightning network)
"""
This app is an example of how you could charge for access to an API using
the lightning network and LND. The example uses a JWT token that grants 1-hour access
(the default jwt token expirey) but many different payment schemes could be
imagined (bulk payments/pay per call etc).
But for now I just wanted to show how simple it could be to add a paywall to an api service.
To use this api:
1. Make a POST request to get a new token and invoice at `/token`