From 8d135489abd4eaf24a3e53a0594184a363569775 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 12 Oct 2020 23:17:50 -0300 Subject: [PATCH] fix: invoice parsing JS bug from the lnurl implementation. --- lnbits/core/static/js/wallet.js | 4 ++-- lnbits/core/views/api.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lnbits/core/static/js/wallet.js b/lnbits/core/static/js/wallet.js index 72f54d49b..21f058dd2 100644 --- a/lnbits/core/static/js/wallet.js +++ b/lnbits/core/static/js/wallet.js @@ -370,7 +370,7 @@ new Vue({ let invoice try { - invoice = decode(this.parse.data.bolt11) + invoice = decode(this.parse.data.request) } catch (error) { this.$q.notify({ timeout: 3000, @@ -416,7 +416,7 @@ new Vue({ }) LNbits.api - .payInvoice(this.g.wallet, this.parse.data.bolt11) + .payInvoice(this.g.wallet, this.parse.data.request) .then(response => { this.parse.paymentChecker = setInterval(() => { LNbits.api diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index 25c1ff4f4..1e292dc33 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -51,7 +51,7 @@ async def api_payments(): "amount": {"type": "integer", "min": 1, "required": True}, "memo": {"type": "string", "empty": False, "required": True, "excludes": "description_hash"}, "description_hash": {"type": "string", "empty": False, "required": True, "excludes": "memo"}, - "lnurl_callback": {"type": "string", "empty": False, "required": False}, + "lnurl_callback": {"type": "string", "nullable": True, "required": False}, } ) async def api_payments_create_invoice(): @@ -73,8 +73,7 @@ async def api_payments_create_invoice(): invoice = bolt11.decode(payment_request) lnurl_response: Union[None, bool, str] = None - if "lnurl_callback" in g.data: - print(g.data["lnurl_callback"]) + if g.data.get("lnurl_callback"): try: r = httpx.get(g.data["lnurl_callback"], params={"pr": payment_request}, timeout=10) if r.is_error: