-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: prepare lndhub for next release (#32)
- add pyproject toml for typing - do not check or change status of payment - do not access fundingsource - general code quality
- Loading branch information
Showing
9 changed files
with
2,200 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
from fastapi import APIRouter | ||
|
||
from lnbits.db import Database | ||
from lnbits.helpers import template_renderer | ||
from .views_api import lndhub_api_router | ||
from .views import lndhub_generic_router | ||
|
||
db = Database("ext_lndhub") | ||
|
||
lndhub_ext: APIRouter = APIRouter(prefix="/lndhub", tags=["lndhub"]) | ||
|
||
lndhub_static_files = [ | ||
{ | ||
"path": "/lndhub/static", | ||
"name": "lndhub_static", | ||
} | ||
] | ||
|
||
|
||
def lndhub_renderer(): | ||
return template_renderer(["lndhub/templates"]) | ||
|
||
|
||
from .decorators import * # noqa: F401,F403 | ||
from .utils import * # noqa: F401,F403 | ||
from .views import * # noqa: F401,F403 | ||
from .views_api import * # noqa: F401,F403 | ||
lndhub_ext.include_router(lndhub_generic_router) | ||
lndhub_ext.include_router(lndhub_api_router) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "LndHub", | ||
"short_description": "Access lnbits from BlueWallet or Zeus", | ||
"short_description": "Access LNbits from BlueWallet or Zeus", | ||
"tile": "/lndhub/static/image/lndhub.png", | ||
"contributors": ["fiatjaf"], | ||
"min_lnbits_version": "0.12.6" | ||
"contributors": ["fiatjaf", "dni"], | ||
"min_lnbits_version": "0.12.11" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from fastapi import Query | ||
from pydantic import BaseModel | ||
|
||
|
||
class LndhubCreateInvoice(BaseModel): | ||
invoice: str = Query(...) | ||
|
||
|
||
class LndhubAddInvoice(BaseModel): | ||
amt: int = Query(...) | ||
memo: str = Query(...) | ||
preimage: str = Query(None) | ||
|
||
|
||
class LndhubAuthData(BaseModel): | ||
login: str = Query(None) | ||
password: str = Query(None) | ||
refresh_token: str = Query(None) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[tool.poetry] | ||
name = "lndhub" | ||
version = "0.5.0" | ||
description = "LNbits LNDHub Extension" | ||
authors = ["dni <[email protected]>"] | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.9" | ||
lnbits = "^0.12.7" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
from lnbits.bolt11 import Invoice | ||
from bolt11 import Bolt11 | ||
|
||
|
||
def to_buffer(payment_hash: str): | ||
return {"type": "Buffer", "data": [b for b in bytes.fromhex(payment_hash)]} | ||
|
||
|
||
def decoded_as_lndhub(invoice: Invoice): | ||
def decoded_as_lndhub(invoice: Bolt11): | ||
return { | ||
"destination": invoice.payee, | ||
"payment_hash": invoice.payment_hash, | ||
"num_satoshis": invoice.amount_msat / 1000, | ||
"num_satoshis": invoice.amount_msat / 1000 if invoice.amount_msat else 0, | ||
"timestamp": str(invoice.date), | ||
"expiry": str(invoice.expiry), | ||
"description": invoice.description, | ||
"fallback_addr": "", | ||
"fallback_addr": invoice.fallback.address if invoice.fallback else "", | ||
"cltv_expiry": invoice.min_final_cltv_expiry, | ||
"route_hints": "", | ||
"route_hints": invoice.route_hints, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters