{"id":13499361,"url":"https://github.com/conscott/get-lightning-paid","last_synced_at":"2025-03-29T04:31:12.865Z","repository":{"id":46344389,"uuid":"157874568","full_name":"conscott/get-lightning-paid","owner":"conscott","description":"Simple Flask API for generating c-lightning invoices and detecting payment using pylightning","archived":false,"fork":false,"pushed_at":"2023-05-22T21:45:34.000Z","size":13,"stargazers_count":4,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T17:39:28.414Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/conscott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-16T13:57:35.000Z","updated_at":"2024-01-19T10:25:52.000Z","dependencies_parsed_at":"2024-10-31T17:32:25.169Z","dependency_job_id":"71ce56bc-243c-4254-b11b-6a2b829e4021","html_url":"https://github.com/conscott/get-lightning-paid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conscott%2Fget-lightning-paid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conscott%2Fget-lightning-paid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conscott%2Fget-lightning-paid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conscott%2Fget-lightning-paid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conscott","download_url":"https://codeload.github.com/conscott/get-lightning-paid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140565,"owners_count":20729797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:00:32.485Z","updated_at":"2025-03-29T04:31:12.622Z","avatar_url":"https://github.com/conscott.png","language":"Python","funding_links":[],"categories":["Developer Resources"],"sub_categories":["Libraries"],"readme":"## Description\n\nA 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!*\n\n### Files\n* API implementation in [app.py](./app.py) \n* Sample usage in script [gen_invoice_and_pay.py](./gen_invoice_and_pay.py)\n\nThe app requires a locally running version of [c-lightning](https://github.com/ElementsProject/lightning)\n\n### Install Environment\n```\nsudo apt-get install python3-dev\npython3 -v venv venv\nsource venv/bin/activate\npip install -r requirements.txt\n```\n\n### Run Server\n\nFor development/test server\n```\n./run_dev.sh\n```\n\nFor production server using uWSGI\n```\n./run_prod.sh\n```\nYou can tweak uwsgi configuration in [uwsgi.ini](./uwsgi.ini)\n\n## API\n\n### Generate Invoice\n\n\n#### POST /api/generate_invoice\n```\n{\n    \"msatoshi\": \u003camount\u003e       (required)\n    \"description\": \u003cstring\u003e    (optional, defatul '')\n    \"expiry\": \u003cseconds\u003e        (optional, default 600)\n}\n```\n\n#### Response\n```\n{\n    \"payment_hash\": \u003cstring\u003e\n    \"expires_at\": \u003cunix timestamp\u003e\n    \"bolt11\": \u003cbolt11 string\u003e\n    \"label\": \u003cstring label_id for payment\u003e\n}\n```\n\nNote the `label` is needed to check invoice status later\n\n### Check Invoice\n\n#### GET /api/check_invoice/\\\u003clabel\\\u003e\nCheck the status of the invoice with the given `label`\n\n#### Response\n```\n{\n    \"status\": \"paid|unpaid|expired\"\n    \"expires_at\": \u003cunix timesamp\u003e\n}\n```\n\n### Wait For Invoice Payment\n\n#### GET /api/wait_invoice/\\\u003clabel\\\u003e\n\nWill wait until the invoice associated with the label has been paid\n\n#### Response\n```\n{\n  \"label\": \u003cstring\u003e\n  \"bolt11\": \u003cstring\u003e\n  \"payment_hash\": \u003cstring\u003e\n  \"msatoshi\": \u003cint\u003e\n  \"status\": \"paid\", \n  \"pay_index\": \u003cint\u003e\n  \"msatoshi_received\": \u003cint\u003e\n  \"paid_at\": \u003cunix timestamp\u003e\n  \"description\": \u003cstring\u003e\n  \"expires_at\": \u003cunix timesamp\u003e\n}\n```\n\n\n### Try it out\n\nCheck out the script [gen_invoice_and_pay.py](./gen_invoice_and_pay.py) to see a sample backend flow\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconscott%2Fget-lightning-paid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconscott%2Fget-lightning-paid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconscott%2Fget-lightning-paid/lists"}