From d91dbbcac3514f900425b7f38ecf49c14f8e1abb Mon Sep 17 00:00:00 2001
From: Tiago vasconcelos
Date: Fri, 11 Jun 2021 16:48:13 +0100
Subject: [PATCH] allow invoices to be generated using Fiat values
---
lnbits/core/static/js/wallet.js | 14 ++++++++++++++
lnbits/core/templates/core/wallet.html | 11 ++++++++++-
lnbits/core/views/api.py | 15 ++++++++++++++-
lnbits/static/js/base.js | 9 ++++++++-
4 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/lnbits/core/static/js/wallet.js b/lnbits/core/static/js/wallet.js
index 7e91278bd..d01910514 100644
--- a/lnbits/core/static/js/wallet.js
+++ b/lnbits/core/static/js/wallet.js
@@ -119,6 +119,8 @@ new Vue({
paymentHash: null,
minMax: [0, 2100000000000000],
lnurl: null,
+ units: ['sat'],
+ unit: 'sat',
data: {
amount: null,
memo: ''
@@ -233,6 +235,7 @@ new Vue({
this.receive.paymentHash = null
this.receive.data.amount = null
this.receive.data.memo = null
+ this.receive.unit = 'sat'
this.receive.paymentChecker = null
this.receive.minMax = [0, 2100000000000000]
this.receive.lnurl = null
@@ -269,11 +272,13 @@ new Vue({
},
createInvoice: function () {
this.receive.status = 'loading'
+
LNbits.api
.createInvoice(
this.g.wallet,
this.receive.data.amount,
this.receive.data.memo,
+ this.receive.unit,
this.receive.lnurl && this.receive.lnurl.callback
)
.then(response => {
@@ -619,6 +624,15 @@ new Vue({
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)
+ })
},
mounted: function () {
// show disclaimer
diff --git a/lnbits/core/templates/core/wallet.html b/lnbits/core/templates/core/wallet.html
index b3f7b1c13..d127b6f9e 100644
--- a/lnbits/core/templates/core/wallet.html
+++ b/lnbits/core/templates/core/wallet.html
@@ -313,12 +313,21 @@
{{receive.lnurl.domain}} is requesting an invoice:
+