feat: update to lnbits 1.0.0 (#66)
--------- Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com> Co-authored-by: Tiago Vasconcelos <talvasconcelos@gmail.com>
This commit is contained in:
parent
3e006654ea
commit
c7623e4c5a
15 changed files with 1372 additions and 1278 deletions
|
|
@ -19,7 +19,8 @@ from pydantic import parse_obj_as
|
|||
from .crud import (
|
||||
get_address_data,
|
||||
get_or_create_lnurlp_settings,
|
||||
increment_pay_link,
|
||||
get_pay_link,
|
||||
update_pay_link,
|
||||
)
|
||||
|
||||
lnurlp_lnurl_router = APIRouter()
|
||||
|
|
@ -36,11 +37,13 @@ async def api_lnurl_callback(
|
|||
amount: int = Query(...),
|
||||
webhook_data: str = Query(None),
|
||||
):
|
||||
link = await increment_pay_link(link_id, served_pr=1)
|
||||
link = await get_pay_link(link_id)
|
||||
if not link:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="Pay link does not exist."
|
||||
)
|
||||
link.served_pr = 1
|
||||
await update_pay_link(link)
|
||||
mininum = link.min
|
||||
maximum = link.max
|
||||
|
||||
|
|
@ -100,7 +103,7 @@ async def api_lnurl_callback(
|
|||
# we take the zap request as the description instead of the metadata if present
|
||||
unhashed_description = nostr.encode() if nostr else link.lnurlpay_metadata.encode()
|
||||
|
||||
_, payment_request = await create_invoice(
|
||||
payment = await create_invoice(
|
||||
wallet_id=link.wallet,
|
||||
amount=int(amount / 1000),
|
||||
memo=link.description,
|
||||
|
|
@ -120,7 +123,7 @@ async def api_lnurl_callback(
|
|||
message = parse_obj_as(Max144Str, link.success_text)
|
||||
action = MessageAction(message=message)
|
||||
|
||||
invoice = parse_obj_as(LightningInvoice, LightningInvoice(payment_request))
|
||||
invoice = parse_obj_as(LightningInvoice, LightningInvoice(payment.bolt11))
|
||||
resp = LnurlPayActionResponse(pr=invoice, successAction=action, routes=[])
|
||||
return resp.dict()
|
||||
|
||||
|
|
@ -136,13 +139,15 @@ async def api_lnurl_callback(
|
|||
name="lnurlp.api_lnurl_response",
|
||||
)
|
||||
async def api_lnurl_response(
|
||||
request: Request, link_id, webhook_data: Optional[str] = Query(None)
|
||||
request: Request, link_id: str, webhook_data: Optional[str] = Query(None)
|
||||
):
|
||||
link = await increment_pay_link(link_id, served_meta=1)
|
||||
link = await get_pay_link(link_id)
|
||||
if not link:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="Pay link does not exist."
|
||||
)
|
||||
link.served_meta = 1
|
||||
await update_pay_link(link)
|
||||
|
||||
rate = await get_fiat_rate_satoshis(link.currency) if link.currency else 1
|
||||
url = request.url_for("lnurlp.api_lnurl_callback", link_id=link.id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue