From 8c2f718c66d86a2c074d5d3f202a91b619ab4d1d Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 15 Mar 2023 00:14:25 +0100 Subject: [PATCH] add lnaddress to extra --- lnurl.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lnurl.py b/lnurl.py index 8b79678..d03faaa 100644 --- a/lnurl.py +++ b/lnurl.py @@ -65,20 +65,25 @@ async def api_lnurl_callback( ).dict() if lnaddress: - domain = urlparse(str(request.url)).netloc - link.domain = domain + # for lnaddress, we have to set this otherwise the metadata won't have the identifier + link.domain = urlparse(str(request.url)).netloc + + extra = { + "tag": "lnurlp", + "link": link.id, + "comment": comment, + "extra": request.query_params.get("amount"), + } + + if lnaddress and link.username and link.domain: + extra["lnaddress"] = f"{link.username}@{link.domain}" payment_hash, payment_request = await create_invoice( wallet_id=link.wallet, amount=int(amount_received / 1000), memo=link.description, unhashed_description=link.lnurlpay_metadata.encode(), - extra={ - "tag": "lnurlp", - "link": link.id, - "comment": comment, - "extra": request.query_params.get("amount"), - }, + extra=extra, ) success_action = link.success_action(payment_hash) @@ -112,9 +117,8 @@ async def api_lnurl_response(request: Request, link_id, lnaddress=False): rate = await get_fiat_rate_satoshis(link.currency) if link.currency else 1 if lnaddress: - # for lnaddress - domain = urlparse(str(request.url)).netloc - link.domain = domain + # for lnaddress, we have to set this otherwise the metadata won't have the identifier + link.domain = urlparse(str(request.url)).netloc callback = request.url_for("lnurlp.api_lnurl_lnaddr_callback", link_id=link.id) else: callback = request.url_for("lnurlp.api_lnurl_callback", link_id=link.id)