diff --git a/lnbits/extensions/cashu/templates/cashu/wallet.html b/lnbits/extensions/cashu/templates/cashu/wallet.html
index 01a5bc1a8..b3ccbc8b9 100644
--- a/lnbits/extensions/cashu/templates/cashu/wallet.html
+++ b/lnbits/extensions/cashu/templates/cashu/wallet.html
@@ -28,7 +28,12 @@ page_container %}
- Sell tokens
(for sats)
@@ -95,10 +100,7 @@ page_container %}
-
+
-
@@ -217,6 +218,51 @@ page_container %}
+
+
+
+
+
+
+ Please paste a Lightning invoice
+
+
+
+
+
+ {% raw %}
+ Amount: {{ sellData.invoice.sat }} sats
+ Description: {{ sellData.invoice.description }}
+ Expire date: {{ sellData.invoice.expireDate }}
+ Expired: {{ sellData.invoice.expired }}
+ Hash: {{ sellData.invoice.hash }} {% endraw %}
+
+
+ Check Invoice
+ Sell Token
+ Close
+
+
+
@@ -276,7 +322,12 @@ page_container %}
bolt11: '',
hash: ''
},
+ sellData: {
+ invoice: '',
+ bolt11: ''
+ },
showInvoiceDetails: false,
+ showPayInvoice: false,
tokens: [],
receive: {
@@ -619,11 +670,18 @@ page_container %}
this.showInvoiceDetails = true
},
- showInvoiceDialog: async function (data) {
+ showInvoiceDialog: function (data) {
this.buyData = _.clone(data)
this.showInvoiceDetails = true
},
+ showPayInvoiceDialog: function () {
+ console.log('### showPayInvoiceDialog')
+ this.sellData.invoice = ''
+ this.sellData.bolt11 = ''
+ this.showPayInvoice = true
+ },
+
requestInvoice: async function () {
try {
const {data} = await LNbits.api.request(
@@ -671,7 +729,7 @@ page_container %}
recheckBuyOrder: async function (hash) {
console.log('### recheckBuyOrder.hash', hash)
- const tokens = this.tokens.find(bt => (bt.hash === hash))
+ const tokens = this.tokens.find(bt => bt.hash === hash)
console.log('### recheckBuyOrder.tokens', tokens)
if (!tokens) {
console.error('####### no token for hash', hash)
@@ -764,6 +822,55 @@ page_container %}
})
},
+ checkInvoice: function () {
+ console.log('#### checkInvoice')
+ try {
+ const invoice = decode(this.sellData.bolt11)
+
+ const cleanInvoice = {
+ msat: invoice.human_readable_part.amount,
+ sat: invoice.human_readable_part.amount / 1000,
+ fsat: LNbits.utils.formatSat(
+ invoice.human_readable_part.amount / 1000
+ )
+ }
+
+ _.each(invoice.data.tags, tag => {
+ if (_.isObject(tag) && _.has(tag, 'description')) {
+ if (tag.description === 'payment_hash') {
+ cleanInvoice.hash = tag.value
+ } else if (tag.description === 'description') {
+ cleanInvoice.description = tag.value
+ } else if (tag.description === 'expiry') {
+ var expireDate = new Date(
+ (invoice.data.time_stamp + tag.value) * 1000
+ )
+ cleanInvoice.expireDate = Quasar.utils.date.formatDate(
+ expireDate,
+ 'YYYY-MM-DDTHH:mm:ss.SSSZ'
+ )
+ cleanInvoice.expired = false // TODO
+ }
+ }
+
+ this.sellData.invoice = cleanInvoice
+ })
+
+ console.log('#### this.sellData.invoice', this.sellData.invoice)
+ } catch (error) {
+ this.$q.notify({
+ timeout: 5000,
+ type: 'warning',
+ message: 'Cannot decode invoice',
+ caption: error + ''
+ })
+ }
+ },
+
+ sellTokens: async function () {
+ console.log('#### sell tokens')
+ },
+
storeBuyOrders: function () {
localStorage.setItem('cashu.buyOrders', JSON.stringify(this.buyOrders))
},
@@ -826,8 +933,8 @@ page_container %}
localStorage.getItem('cashu.buyOrders') || '[]'
)
this.tokens = JSON.parse(localStorage.getItem('cashu.tokens') || '[]')
- // console.table(this.buyOrders)
- // console.table(this.tokens)
+ console.log('### buyOrders',this.buyOrders)
+ console.table('### tokens',this.tokens)
console.log('#### this.mintId', this.mintId)
console.log('#### this.mintName', this.mintName)