From ffe6f0d216030f5c9d945ba28a485be303a68883 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Fri, 4 Nov 2022 16:16:15 +0100 Subject: [PATCH] trying to get camera to run --- .../cashu/templates/cashu/wallet.html | 257 ++++++++++++++++-- 1 file changed, 238 insertions(+), 19 deletions(-) diff --git a/lnbits/extensions/cashu/templates/cashu/wallet.html b/lnbits/extensions/cashu/templates/cashu/wallet.html index e4621e11..110ecfa2 100644 --- a/lnbits/extensions/cashu/templates/cashu/wallet.html +++ b/lnbits/extensions/cashu/templates/cashu/wallet.html @@ -45,7 +45,7 @@ page_container %}
-
+
Receive Tokens
-
-
+
+
- + + + + + + + +
+
+ {% raw %} {{ parseFloat(String(parse.invoice.fsat).replaceAll(",", + "")) / 100 }} {% endraw %} {{LNBITS_DENOMINATION}} {% raw %} +
+
+ {{ parse.invoice.fsat }}{% endraw %} {{LNBITS_DENOMINATION}} {% + raw %} +
+ +

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

+ {% endraw %} +
+ Pay + Cancel +
+
+ Not enough funds! + Cancel +
+
+
+ {% raw %} + +

+ Authenticate with {{ parse.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 }}. +

+

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

+

+ {{ parse.lnurlauth.pubkey }} +

+
+ Login + Cancel +
+
+ {% endraw %} +
+
+ {% raw %} + +

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

+

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

+ +
+

+ {{ parse.lnurlpay.description }} +

+

+ +

+
+
+
+ {% endraw %} + + {% raw %} +
+
+ +
+
+
+ Send {{LNBITS_DENOMINATION}} + Cancel +
+
+ {% endraw %} +
+
+ + + +
+ Read + Cancel +
+
+
+ + + +
+ + Cancel + +
+
+
+
+
+ + + +
+ +
+
+ Cancel +
+
+
+
Warning
@@ -493,7 +693,11 @@ page_container %} invoiceCheckListener: () => {}, payInvoiceData: { invoice: '', - bolt11: '' + bolt11: '', + camera: { + show: false, + camera: 'auto' + } }, sendData: { amount: 0, @@ -923,6 +1127,7 @@ page_container %} this.payInvoiceData.invoice = '' this.payInvoiceData.bolt11 = '' this.showPayInvoice = true + this.payInvoiceData.camera.show = false }, showSendTokensDialog: function () { @@ -1131,6 +1336,10 @@ page_container %} this.proofs[i].reserved = true } } + + // delete tokens from db + this.proofs = fristProofs + // add new fristProofs, scndProofs to this.proofs this.storeProofs() return {fristProofs, scndProofs} } catch (error) { @@ -1250,28 +1459,37 @@ page_container %} this.sendData.tokensBase64 = btoa(JSON.stringify(this.sendData.tokens)) // delete tokens from db - this.proofs = fristProofs + // this.proofs = fristProofs // add new fristProofs, scndProofs to this.proofs - this.storeProofs() + // this.storeProofs() }, melt: async function () { - console.log('#### sell tokens') + console.log('#### pay lightning') const amount = this.payInvoiceData.invoice.sat - const paidTokens = this.proofs.filter(t => t.promises?.length) - console.log('### paidTokens', paidTokens) - const proofs = paidTokens.map(token => { - return token.promises.map((promise, promiseIndex) => { - console.log('### promise', promise) + // if (amount > balance()) { + // LNbits.utils.notifyApiError('Balance too low') + // return + // } + let {fristProofs, scndProofs} = await this.splitToSend( + this.proofs, + amount + ) - const secret = token.secrets[promiseIndex] - const r = token.rs[promiseIndex] + // const paidTokens = this.proofs.filter(t => t.promises?.length) + // console.log('### paidTokens', paidTokens) + // const proofs = paidTokens.map(token => { + // return token.promises.map((promise, promiseIndex) => { + // console.log('### promise', promise) - return this.promiseToProof(promise.amount, promise['C_'], secret, r) - }) - }) + // const secret = token.secrets[promiseIndex] + // const r = token.rs[promiseIndex] + + // return this.promiseToProof(promise.amount, promise['C_'], secret, r) + // }) + // }) const payload = { - proofs: proofs.flat(), + proofs: scndProofs.flat(), amount, invoice: this.payInvoiceData.bolt11 } @@ -1285,6 +1503,7 @@ page_container %} ) this.$q.notify({ timeout: 5000, + type: 'positive', message: 'Invoice paid' }) } catch (error) {