diff --git a/lnbits/extensions/cashu/templates/cashu/wallet.html b/lnbits/extensions/cashu/templates/cashu/wallet.html index 110ecfa22..56104d50a 100644 --- a/lnbits/extensions/cashu/templates/cashu/wallet.html +++ b/lnbits/extensions/cashu/templates/cashu/wallet.html @@ -202,22 +202,25 @@ page_container %} - + -
+
- {% raw %} {{ parseFloat(String(parse.invoice.fsat).replaceAll(",", + {% raw %} {{ + parseFloat(String(payInvoiceData.invoice.fsat).replaceAll(",", "")) / 100 }} {% endraw %} {{LNBITS_DENOMINATION}} {% raw %}
- {{ parse.invoice.fsat }}{% endraw %} {{LNBITS_DENOMINATION}} {% - raw %} + {{ payInvoiceData.invoice.fsat }}{% endraw %} + {{LNBITS_DENOMINATION}} {% raw %}

- Description: {{ parse.invoice.description }}
- Expire date: {{ parse.invoice.expireDate }}
- Hash: {{ parse.invoice.hash }} + Description: {{ + payInvoiceData.invoice.description }}
+ Expire date: {{ payInvoiceData.invoice.expireDate + }}
+ Hash: {{ payInvoiceData.invoice.hash }}

{% endraw %}
@@ -235,22 +238,27 @@ page_container %} >
-
+
{% raw %}

- Authenticate with {{ parse.lnurlauth.domain }}? + Authenticate with {{ payInvoiceData.lnurlauth.domain }}?

For every website and for every LNbits wallet, a new keypair will be deterministically generated so your identity can't be tied to your LNbits wallet or linked across websites. No other - data will be shared with {{ parse.lnurlauth.domain }}. + data will be shared with {{ payInvoiceData.lnurlauth.domain }}. +

+

+ Your public key for + {{ payInvoiceData.lnurlauth.domain }} is:

-

Your public key for {{ parse.lnurlauth.domain }} is:

- {{ parse.lnurlauth.pubkey }} + + {{ payInvoiceData.lnurlauth.pubkey }} +

Login @@ -261,37 +269,45 @@ page_container %} {% endraw %}
-
+
{% raw %} -

- {{ parse.lnurlpay.domain }} is requesting {{ - parse.lnurlpay.maxSendable | msatoshiFormat }} +

+ {{ payInvoiceData.lnurlpay.domain }} is requesting {{ + payInvoiceData.lnurlpay.maxSendable | msatoshiFormat }} {{LNBITS_DENOMINATION}} - +
- and a {{parse.lnurlpay.commentAllowed}}-char comment + and a {{payInvoiceData.lnurlpay.commentAllowed}}-char comment

- {{ parse.lnurlpay.targetUser || parse.lnurlpay.domain }} + {{ payInvoiceData.lnurlpay.targetUser || + payInvoiceData.lnurlpay.domain }} is requesting
between - {{ parse.lnurlpay.minSendable | msatoshiFormat }} and - {{ parse.lnurlpay.maxSendable | msatoshiFormat }} + {{ payInvoiceData.lnurlpay.minSendable | msatoshiFormat }} + and + {{ payInvoiceData.lnurlpay.maxSendable | msatoshiFormat }} {% endraw %} {{LNBITS_DENOMINATION}} {% raw %} - +
- and a {{parse.lnurlpay.commentAllowed}}-char comment + and a {{payInvoiceData.lnurlpay.commentAllowed}}-char comment

- {{ parse.lnurlpay.description }} + {{ payInvoiceData.lnurlpay.description }}

-

- +

+

@@ -300,26 +316,26 @@ page_container %} {% raw %}
@@ -336,14 +352,15 @@ page_container %}
@@ -352,7 +369,7 @@ page_container %} Read @@ -378,7 +395,7 @@ page_container %} - +
{}, payInvoiceData: { - invoice: '', + // invoice: '', bolt11: '', + // camera: { + // show: false, + // camera: 'auto' + // } + show: false, + invoice: null, + lnurlpay: null, + lnurlauth: null, + data: { + request: '', + amount: 0, + comment: '' + }, + paymentChecker: null, camera: { show: false, camera: 'auto' @@ -846,8 +878,8 @@ page_container %} }, canPay: function () { - if (!this.parse.invoice) return false - return this.parse.invoice.sat <= this.balance + if (!this.payInvoiceData.invoice) return false + return this.payInvoiceData.invoice.sat <= this.balance }, pendingPaymentsExist: function () { return this.payments.findIndex(payment => payment.pending) !== -1 @@ -884,10 +916,10 @@ page_container %} return row.payment_hash + row.amount }, closeCamera: function () { - this.parse.camera.show = false + this.payInvoiceData.camera.show = false }, showCamera: function () { - this.parse.camera.show = true + this.payInvoiceData.camera.show = true }, showChart: function () { this.paymentsChart.show = true @@ -912,14 +944,15 @@ page_container %} this.focusInput('setAmount') }, showParseDialog: function () { - this.parse.show = true - this.parse.invoice = null - this.parse.lnurlpay = null - this.parse.lnurlauth = null - this.parse.data.request = '' - this.parse.data.comment = '' - this.parse.data.paymentChecker = null - this.parse.camera.show = false + this.payInvoiceData.show = true + this.payInvoiceData.invoice = null + this.payInvoiceData.lnurlpay = null + this.payInvoiceData.lnurlauth = null + this.payInvoiceData.data.request = '' + this.payInvoiceData.data.comment = '' + this.payInvoiceData.data.paymentChecker = null + this.payInvoiceData.camera.show = false + this.focusInput('pasteInput') }, closeReceiveDialog: function () { @@ -929,7 +962,7 @@ page_container %} }, closeParseDialog: function () { setTimeout(() => { - clearInterval(this.parse.paymentChecker) + clearInterval(this.payInvoiceData.paymentChecker) }, 10000) }, onPaymentReceived: function (paymentHash) { @@ -994,33 +1027,43 @@ page_container %} }) }, decodeQR: function (res) { - this.parse.data.request = res + this.payInvoiceData.data.request = res this.decodeRequest() - this.parse.camera.show = false + this.payInvoiceData.camera.show = false }, decodeRequest: function () { - this.parse.show = true - let req = this.parse.data.request.toLowerCase() - if (this.parse.data.request.toLowerCase().startsWith('lightning:')) { - this.parse.data.request = this.parse.data.request.slice(10) - } else if (this.parse.data.request.toLowerCase().startsWith('lnurl:')) { - this.parse.data.request = this.parse.data.request.slice(6) + this.payInvoiceData.show = true + let req = this.payInvoiceData.data.request.toLowerCase() + if ( + this.payInvoiceData.data.request + .toLowerCase() + .startsWith('lightning:') + ) { + this.payInvoiceData.data.request = this.payInvoiceData.data.request.slice( + 10 + ) + } else if ( + this.payInvoiceData.data.request.toLowerCase().startsWith('lnurl:') + ) { + this.payInvoiceData.data.request = this.payInvoiceData.data.request.slice( + 6 + ) } else if (req.indexOf('lightning=lnurl1') !== -1) { - this.parse.data.request = this.parse.data.request + this.payInvoiceData.data.request = this.payInvoiceData.data.request .split('lightning=')[1] .split('&')[0] } if ( - this.parse.data.request.toLowerCase().startsWith('lnurl1') || - this.parse.data.request.match(/[\w.+-~_]+@[\w.+-~_]/) + this.payInvoiceData.data.request.toLowerCase().startsWith('lnurl1') || + this.payInvoiceData.data.request.match(/[\w.+-~_]+@[\w.+-~_]/) ) { return } let invoice try { - invoice = decode(this.parse.data.request) + invoice = decode(this.payInvoiceData.data.request) } catch (error) { this.$q.notify({ timeout: 3000, @@ -1028,7 +1071,7 @@ page_container %} message: error + '.', caption: '400 BAD REQUEST' }) - this.parse.show = false + this.payInvoiceData.show = false throw error return } @@ -1060,7 +1103,7 @@ page_container %} } }) - this.parse.invoice = Object.freeze(cleanInvoice) + this.payInvoiceData.invoice = Object.freeze(cleanInvoice) }, payInvoice: function () { let dismissPaymentMsg = this.$q.notify({ @@ -1125,7 +1168,7 @@ page_container %} showPayInvoiceDialog: function () { console.log('### showPayInvoiceDialog') this.payInvoiceData.invoice = '' - this.payInvoiceData.bolt11 = '' + this.payInvoiceData.data.request = '' this.showPayInvoice = true this.payInvoiceData.camera.show = false }, @@ -1491,7 +1534,7 @@ page_container %} const payload = { proofs: scndProofs.flat(), amount, - invoice: this.payInvoiceData.bolt11 + invoice: this.payInvoiceData.data.request } console.log('#### payload', JSON.stringify(payload)) try { @@ -1506,6 +1549,8 @@ page_container %} type: 'positive', message: 'Invoice paid' }) + this.payInvoiceData.invoice = null + this.payInvoiceData.show = false } catch (error) { console.error(error) LNbits.utils.notifyApiError(error) @@ -1645,7 +1690,7 @@ page_container %} checkInvoice: function () { console.log('#### checkInvoice') try { - const invoice = decode(this.payInvoiceData.bolt11) + const invoice = decode(this.payInvoiceData.data.request) const cleanInvoice = { msat: invoice.human_readable_part.amount, @@ -1709,7 +1754,7 @@ page_container %} // const payload = { // proofs: proofs.flat(), // amount, - // invoice: this.payInvoiceData.bolt11 + // invoice: this.payInvoiceData.data.request // } // console.log('#### payload', JSON.stringify(payload)) // try {