mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-27 12:26:19 +02:00
fix lnurlwallet flow.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import trio # type: ignore
|
||||||
import json
|
import json
|
||||||
import httpx
|
import httpx
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
@@ -182,6 +183,7 @@ async def redeem_lnurl_withdraw(
|
|||||||
lnurl_request: str,
|
lnurl_request: str,
|
||||||
memo: Optional[str] = None,
|
memo: Optional[str] = None,
|
||||||
extra: Optional[Dict] = None,
|
extra: Optional[Dict] = None,
|
||||||
|
wait_seconds: int = 0,
|
||||||
conn: Optional[Connection] = None,
|
conn: Optional[Connection] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
res = {}
|
res = {}
|
||||||
@@ -199,19 +201,28 @@ async def redeem_lnurl_withdraw(
|
|||||||
conn=conn,
|
conn=conn,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if wait_seconds:
|
||||||
|
await trio.sleep(wait_seconds)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
"k1": res["k1"],
|
||||||
|
"pr": payment_request,
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
params["balanceNotify"] = url_for(
|
||||||
|
"core.lnurl_balance_notify",
|
||||||
|
service=urlparse(lnurl_request).netloc,
|
||||||
|
wal=wallet_id,
|
||||||
|
_external=True,
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
await client.get(
|
await client.get(
|
||||||
res["callback"],
|
res["callback"],
|
||||||
params={
|
params=params,
|
||||||
"k1": res["k1"],
|
|
||||||
"pr": payment_request,
|
|
||||||
"balanceNotify": url_for(
|
|
||||||
"core.lnurl_balance_notify",
|
|
||||||
service=urlparse(lnurl_request).netloc,
|
|
||||||
wal=wallet_id,
|
|
||||||
_external=True,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import trio # type: ignore
|
|
||||||
from os import path
|
from os import path
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from quart import (
|
from quart import (
|
||||||
@@ -203,8 +202,9 @@ async def lnurlwallet():
|
|||||||
wallet.id,
|
wallet.id,
|
||||||
request.args.get("lightning"),
|
request.args.get("lightning"),
|
||||||
"LNbits initial funding: voucher redeem.",
|
"LNbits initial funding: voucher redeem.",
|
||||||
|
{"tag": "lnurlwallet"},
|
||||||
|
5, # wait 5 seconds before sending the invoice to the service
|
||||||
)
|
)
|
||||||
await trio.sleep(3)
|
|
||||||
|
|
||||||
return redirect(url_for("core.wallet", usr=user.id, wal=wallet.id))
|
return redirect(url_for("core.wallet", usr=user.id, wal=wallet.id))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user