diff --git a/lnbits/extensions/cashu/templates/cashu/index.html b/lnbits/extensions/cashu/templates/cashu/index.html index 37dc360e..4e5ba911 100644 --- a/lnbits/extensions/cashu/templates/cashu/index.html +++ b/lnbits/extensions/cashu/templates/cashu/index.html @@ -49,7 +49,7 @@ icon="launch" :color="($q.dark.isActive) ? 'grey-7' : 'grey-5'" type="a" - :href="'wallet/?tsh=' + props.row.tickershort + '&mnt=' + hostname + props.row.id + '&nme=' + props.row.name" + :href="'wallet/?tsh=' + (props.row.tickershort || '') + '&mint_id=' + props.row.id + '&mint_name=' + props.row.name" target="_blank" >Shareable wallet page diff --git a/lnbits/extensions/cashu/templates/cashu/wallet.html b/lnbits/extensions/cashu/templates/cashu/wallet.html index 3fa8028c..de5cb7b6 100644 --- a/lnbits/extensions/cashu/templates/cashu/wallet.html +++ b/lnbits/extensions/cashu/templates/cashu/wallet.html @@ -14,8 +14,8 @@ page_container %} rounded color="secondary" class="full-width" - @click="showCamera" - >Buy tokens + @click="showBuyTokensDialog" + >Buy tokens
(with sats)
@@ -28,12 +28,7 @@ page_container %}
- Sell tokens
(for sats)
@@ -52,7 +47,6 @@ page_container %} rounded color="primary" class="full-width" - @click="showParseDialog" >Receive
@@ -63,7 +57,6 @@ page_container %} rounded color="primary" class="full-width" - @click="showSendDialog" > Send @@ -75,7 +68,6 @@ page_container %} color="secondary" icon="sync_alt" class="full-width" - @click="showCamera" >Peg in/out @@ -86,7 +78,6 @@ page_container %} color="secondary" icon="photo_camera" class="full-width" - @click="showCamera" >scan @@ -107,23 +98,14 @@ page_container %} icon="approval" color="grey" type="a" - :href="mint" + :href="mintName" target="_blank" >{% endraw %} Mint details - Export to CSV + Export to CSV - + Show chart @@ -244,12 +226,7 @@ page_container %}
- Copy invoice + Copy invoice - - + + @@ -557,18 +530,72 @@ page_container %} lose the funds.

- Copy wallet URL + Copy wallet URL I understand
+ + + {% raw %} + + +
+
+
+ How much would you like to buy? +
+
+ + + +
+ +
+ Copy invoice + Request Invoice + Close +
+
+ {% endraw %} +
@@ -605,6 +632,8 @@ page_container %} return obj } + Vue.component(VueQrcode.name, VueQrcode) + new Vue({ el: '#vue', mixins: [windowMixin], @@ -613,6 +642,17 @@ page_container %} balanceAmount: '', tickershort: '', name: '', + + mintId: '', + mintName: '', + buyTokens: { + showDialog: false, + amount: 0, + memo: '', + bolt11: '', + hash: '' + }, + receive: { show: false, status: 'pending', @@ -933,6 +973,28 @@ page_container %} field: 'pending' }) LNbits.utils.exportCSV(columns, this.payments) + }, + + /////////////////////////////////// WALLET /////////////////////////////////// + showBuyTokensDialog: async function () { + this.buyTokens.amount = 0 + this.buyTokens.bolt11 = '' + this.buyTokens.hash = '' + this.buyTokens.memo = '' + this.buyTokens.showDialog = true + }, + requestInvoice: async function () { + try { + const {data} = await LNbits.api.request( + 'GET', + `/cashu/api/v1/cashu/${this.mintId}/mint?amount=${this.buyTokens.amount}` + ) + console.log('### data', data) + this.buyTokens.bolt11 = data.pr + this.buyTokens.hash = data.hash + } catch (error) { + LNbits.utils.notifyApiError(error) + } } }, watch: { @@ -940,19 +1002,7 @@ page_container %} this.fetchBalance() } }, - created: function () { - this.fetchBalance() - this.fetchPayments() - LNbits.api - .request('GET', '/api/v1/currencies') - .then(response => { - this.receive.units = ['sat', ...response.data] - }) - .catch(err => { - LNbits.utils.notifyApiError(err) - }) - }, created: function () { let params = new URL(document.location).searchParams @@ -975,11 +1025,11 @@ page_container %} } // get mint - if (params.get('mnt')) { - this.mint = params.get('mnt') - this.$q.localStorage.set('cashu.mint', params.get('mnt')) + if (params.get('mint_id')) { + this.mintId = params.get('mint_id') + this.$q.localStorage.set('cashu.mint', params.get('mint_id')) } else if (this.$q.localStorage.getItem('cashu.mint')) { - this.mint = this.$q.localStorage.getItem('cashu.mint') + this.mintId = this.$q.localStorage.getItem('cashu.mint') } else { this.$q.notify({ color: 'red', @@ -988,12 +1038,14 @@ page_container %} } // get name - if (params.get('nme')) { - this.name = params.get('nme') - this.$q.localStorage.set('cashu.name', params.get('nme')) + if (params.get('mint_name')) { + this.mintName = params.get('mint_name') + this.$q.localStorage.set('cashu.mintName', params.get('mint_name')) } else if (this.$q.localStorage.getItem('cashu.name')) { - this.name = this.$q.localStorage.getItem('cashu.name') + this.mintName = this.$q.localStorage.getItem('cashu.name') } + console.log('#### this.mintId', this.mintId) + console.log('#### this.mintName', this.mintName) } })