diff --git a/lnurl.py b/lnurl.py index e3ac7f1..4b39374 100644 --- a/lnurl.py +++ b/lnurl.py @@ -75,14 +75,22 @@ async def api_scan(p, c, request: Request, external_id: str): if hits_amount > card.daily_limit: return {"status": "ERROR", "reason": "Max daily limit spent."} hit = await create_hit(card.id, ip, agent, card.counter, ctr_int) - lnurlpay = lnurl_encode(str(request.url_for("boltcards.lnurlp_response", hit_id=hit.id))) + + # the raw lnurl + lnurlpay_raw = str(request.url_for("boltcards.lnurlp_response", hit_id=hit.id)) + # bech32 encoded lnurl + lnurlpay_bech32 = lnurl_encode(lnurlpay_raw) + # create a lud17 lnurlp to support lud19, add to payLink field of the withdrawRequest + lnurlpay_nonbech32_lud17 = lnurlpay_raw.replace("https://", "lnurlp://").replace("http://","lnurlp://") + return { "tag": "withdrawRequest", "callback": str(request.url_for("boltcards.lnurl_callback", hit_id=hit.id)), "k1": hit.id, "minWithdrawable": 1 * 1000, "maxWithdrawable": card.tx_limit * 1000, - "defaultDescription": f"Boltcard (refund address lnurl://{lnurlpay})", + "defaultDescription": f"Boltcard (refund address lnurl://{lnurlpay_bech32})", + "payLink": lnurlpay_nonbech32_lud17, # LUD-19 compatibility }