add support for LUD-19 for boltcards extension (#19)
* fix broken link for tag, boltcard -> boltcards (name of the extension) * add support for LUD-19 in bolt cards extension * Apply suggestions from code review Co-authored-by: Pavol Rusnak <pavol@rusnak.io> * Apply suggestions from code review Co-authored-by: Pavol Rusnak <pavol@rusnak.io> --------- Co-authored-by: Jan Dvorak <jan.dvorak@xorux.com> Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
This commit is contained in:
parent
21d826c2a4
commit
76fcd30ac0
1 changed files with 10 additions and 2 deletions
12
lnurl.py
12
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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue