diff --git a/static/js/index.js b/static/js/index.js index 8562385..abdf4a7 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -27,6 +27,9 @@ window.app = Vue.createApp({ }, data() { return { + tab: 'bech32', + url: window.location.origin + '/lnurlp/api/v1/lnurl/', + lnurl: '', settings: [ { type: 'str', @@ -100,6 +103,13 @@ window.app = Vue.createApp({ } }, methods: { + setBech32() { + const url = + window.location.origin + '/lnurlp/' + this.qrCodeDialog.data.id + const bytes = new TextEncoder().encode(url) + const bech32 = NostrTools.nip19.encodeBytes('lnurl', bytes) + this.lnurl = `lightning:${bech32.toUpperCase()}` + }, getPayLinks() { LNbits.api .request( @@ -144,6 +154,7 @@ window.app = Vue.createApp({ print_url: link.print_url, username: link.username } + this.setBech32() this.qrCodeDialog.show = true }, openUpdateDialog(linkId) { @@ -275,12 +286,23 @@ window.app = Vue.createApp({ } } }, + watch: { + tab(value) { + if (value == 'bech32') { + this.setBech32() + } else if (value == 'lud17') { + const url = + window.location.origin + '/lnurlp/' + this.qrCodeDialog.data.id + this.lnurl = url.replace('https://', 'lnurlp://') + } + } + }, created() { if (this.g.user.wallets?.length) { this.getPayLinks() } LNbits.api - .request('GET', '/lnurlp/api/v1/currencies') + .request('GET', '/api/v1/currencies') .then(response => { this.currencies = ['satoshis', ...response.data] }) diff --git a/templates/lnurlp/display.html b/templates/lnurlp/display.html index f8fe2a6..a14e55e 100644 --- a/templates/lnurlp/display.html +++ b/templates/lnurlp/display.html @@ -2,21 +2,36 @@
+ + + + + +
- Copy LNURL
@@ -40,7 +55,33 @@ {% endblock %} diff --git a/templates/lnurlp/index.html b/templates/lnurlp/index.html index 33c9125..1eaeab4 100644 --- a/templates/lnurlp/index.html +++ b/templates/lnurlp/index.html @@ -357,9 +357,22 @@ - + + + + + + +

ID:
Amount: Copy LNURL @@ -407,7 +420,7 @@ outline color="grey" icon="nfc" - @click="writeNfcTag(qrCodeDialog.data.lnurl)" + @click="writeNfcTag(lnurl)" :disable="nfcTagWriting" >Write to NFC diff --git a/views.py b/views.py index 1ad3ff8..78ebcde 100644 --- a/views.py +++ b/views.py @@ -30,7 +30,7 @@ async def display(request: Request, link_id): raise HTTPException( status_code=HTTPStatus.NOT_FOUND, detail="Pay link does not exist." ) - ctx = {"request": request, "lnurl": link.lnurl(req=request)} + ctx = {"request": request, "link_id": link.id} return lnurlp_renderer().TemplateResponse("lnurlp/display.html", ctx) diff --git a/views_lnurl.py b/views_lnurl.py index b30ff35..462486f 100644 --- a/views_lnurl.py +++ b/views_lnurl.py @@ -132,13 +132,11 @@ async def api_lnurl_callback( @lnurlp_lnurl_router.get( "/api/v1/lnurl/{link_id}", # Backwards compatibility for old LNURLs / QR codes - status_code=HTTPStatus.OK, name="lnurlp.api_lnurl_response.deprecated", deprecated=True, ) @lnurlp_lnurl_router.get( "/{link_id}", - status_code=HTTPStatus.OK, name="lnurlp.api_lnurl_response", ) async def api_lnurl_response(