From 75e78d2ab6fd6a4d965e8cadae51821a7be91658 Mon Sep 17 00:00:00 2001 From: benarc Date: Wed, 2 Feb 2022 17:28:00 +0000 Subject: [PATCH] FakeWallet own denomination now working --- lnbits/core/static/js/wallet.js | 55 ++++++++++++++------------ lnbits/core/templates/core/wallet.html | 49 ++++++++++++++++------- lnbits/static/js/components.js | 10 +++-- lnbits/templates/base.html | 2 + 4 files changed, 72 insertions(+), 44 deletions(-) diff --git a/lnbits/core/static/js/wallet.js b/lnbits/core/static/js/wallet.js index ac88549ce..8d58302bf 100644 --- a/lnbits/core/static/js/wallet.js +++ b/lnbits/core/static/js/wallet.js @@ -161,14 +161,14 @@ new Vue({ { name: 'sat', align: 'right', - label: 'Amount (sat)', + label: 'Amount (' + LNBITS_DENOMINATION + ')', field: 'sat', sortable: true }, { name: 'fee', align: 'right', - label: 'Fee (msat)', + label: 'Fee (m' + LNBITS_DENOMINATION + ')', field: 'fee' } ], @@ -191,7 +191,11 @@ new Vue({ }, computed: { formattedBalance: function () { - return LNbits.utils.formatSat(this.balance || this.g.wallet.sat) + if (LNBITS_DENOMINATION != 'sats') { + return this.balance / 100 + } else { + return LNbits.utils.formatSat(this.balance || this.g.wallet.sat) + } }, filteredPayments: function () { var q = this.paymentsTable.filter @@ -250,28 +254,27 @@ new Vue({ this.parse.data.paymentChecker = null this.parse.camera.show = false }, - updateBalance: function(credit){ + updateBalance: function (credit) { + if (LNBITS_DENOMINATION != 'sats') { + credit = credit * 100 + } LNbits.api - .request( - 'PUT', - '/api/v1/wallet/balance/' + credit, - this.g.wallet.inkey - ) - .catch(err => { - LNbits.utils.notifyApiError(err) - }) - .then(response => { - let data = response.data - if (data.status === 'ERROR') { - this.$q.notify({ - timeout: 5000, - type: 'warning', - message: `Failed to update.`, - }) - return - } - this.balance = this.balance + data.balance - }) + .request('PUT', '/api/v1/wallet/balance/' + credit, this.g.wallet.inkey) + .catch(err => { + LNbits.utils.notifyApiError(err) + }) + .then(response => { + let data = response.data + if (data.status === 'ERROR') { + this.$q.notify({ + timeout: 5000, + type: 'warning', + message: `Failed to update.` + }) + return + } + this.balance = this.balance + data.balance + }) }, closeReceiveDialog: function () { setTimeout(() => { @@ -295,7 +298,9 @@ new Vue({ }, createInvoice: function () { this.receive.status = 'loading' - + if (LNBITS_DENOMINATION != 'sats') { + this.receive.data.amount = this.receive.data.amount * 100 + } LNbits.api .createInvoice( this.g.wallet, diff --git a/lnbits/core/templates/core/wallet.html b/lnbits/core/templates/core/wallet.html index 3edfbb7e4..189d1547f 100644 --- a/lnbits/core/templates/core/wallet.html +++ b/lnbits/core/templates/core/wallet.html @@ -35,7 +35,9 @@ v-model="scope.value" dense autofocus - type="number" + mask="#.##" + fill-mask="0" + reverse-fill-mask @keyup.enter="updateBalance(scope.value)" >