Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/conscott/get-lightning-paid
Simple Flask API for generating c-lightning invoices and detecting payment using pylightning
https://github.com/conscott/get-lightning-paid
Last synced: about 1 month ago
JSON representation
Simple Flask API for generating c-lightning invoices and detecting payment using pylightning
- Host: GitHub
- URL: https://github.com/conscott/get-lightning-paid
- Owner: conscott
- Created: 2018-11-16T13:57:35.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-22T21:45:34.000Z (over 1 year ago)
- Last Synced: 2024-08-01T22:51:00.145Z (4 months ago)
- Language: Python
- Homepage:
- Size: 12.7 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-lightning-network - get-lightning-paid - A Flask REST API to generate lightning invoices and payment confirmations (Developer Resources / Libraries)
- awesome-lightning-network - get-lightning-paid - A Flask REST API to generate lightning invoices and payment confirmations (Developer Resources / Libraries)
README
## Description
A simple Flask REST API to generate lightning invoices and wait for payment confirmation / check invoice status. This is experimential fun and not enterprise ready. *Use with caution!*
### Files
* API implementation in [app.py](./app.py)
* Sample usage in script [gen_invoice_and_pay.py](./gen_invoice_and_pay.py)The app requires a locally running version of [c-lightning](https://github.com/ElementsProject/lightning)
### Install Environment
```
sudo apt-get install python3-dev
python3 -v venv venv
source venv/bin/activate
pip install -r requirements.txt
```### Run Server
For development/test server
```
./run_dev.sh
```For production server using uWSGI
```
./run_prod.sh
```
You can tweak uwsgi configuration in [uwsgi.ini](./uwsgi.ini)## API
### Generate Invoice
#### POST /api/generate_invoice
```
{
"msatoshi": (required)
"description": (optional, defatul '')
"expiry": (optional, default 600)
}
```#### Response
```
{
"payment_hash":
"expires_at":
"bolt11":
"label":
}
```Note the `label` is needed to check invoice status later
### Check Invoice
#### GET /api/check_invoice/\
Check the status of the invoice with the given `label`#### Response
```
{
"status": "paid|unpaid|expired"
"expires_at":
}
```### Wait For Invoice Payment
#### GET /api/wait_invoice/\
Will wait until the invoice associated with the label has been paid
#### Response
```
{
"label":
"bolt11":
"payment_hash":
"msatoshi":
"status": "paid",
"pay_index":
"msatoshi_received":
"paid_at":
"description":
"expires_at":
}
```### Try it out
Check out the script [gen_invoice_and_pay.py](./gen_invoice_and_pay.py) to see a sample backend flow