From 1950999528dd2ab448bee8ccf3ff910b0256127f Mon Sep 17 00:00:00 2001
From: bitkarrot <73979971+bitkarrot@users.noreply.github.com>
Date: Sun, 7 Jan 2024 12:48:09 -0800
Subject: [PATCH] fix formatting for invoice
---
templates/decoder/index.html | 51 ++++++++++++++++++++++--------------
1 file changed, 31 insertions(+), 20 deletions(-)
diff --git a/templates/decoder/index.html b/templates/decoder/index.html
index 81e3dcd..582facb 100644
--- a/templates/decoder/index.html
+++ b/templates/decoder/index.html
@@ -51,24 +51,7 @@
-
-
-
-
-
-
{% raw %} {{ key }} {% endraw %}:
-
- -
- {% raw %} {{ innerKey }} {% endraw %}:{% raw %} {{ innerValue }}{% endraw %}
-
-
-
-
- {% raw %} {{ key }} {% endraw %}:
- {% raw %} {{ value }} {% endraw %}
-
-
-
+
@@ -146,7 +129,9 @@
lnurlData: '',
lnaddress: '',
lnaddressData: '',
- };
+ //invoiceData: '- currency: tb
- amount_msat: 100000
- date: 1704445244
- signature: 5db7f1dd76747dc4f7d562f1c2c857c55f1d1d21ccc9996d784cb3545bce118942844d1f07991b0f5e64fc4e65fb9b264693c30637f79799c138b9d7db0e66e6
- payment_hash: e4c14a85db066817985c9cdcac76dc4c873039aa2974b7a33d1f93a32335d5c2
- payment_secret: 05adfd4de6838ba3da4c507eec8038f0b8c4ae085d34dd41cbf6f8886bbc5803
- description: Testnet LNbits
- features:
- var_onion_optin: required
- payment_secret: required
- basic_mpp: supported
- route_hints:
- 0:
- 0:
- public_key: 020ec0c6a0c4fe5d8a79928ead294c36234a76f6e0dca896c35413612a3fd8dbf8
- short_channel_id: 2474998x29x1
- base_fee: 1000
- ppm_fee: 1000
- cltv_expiry_delta: 80
- min_final_cltv_expiry: 10
- payee: 03ba00a57cec1cef4873065ad54d0912696274cc53155b29a3b1256720e33a0943
',
+ invoiceData: '',
+ };
},
mounted() {
},
@@ -203,14 +188,37 @@
console.error('There was a problem with the fetch operation:', error);
}
},
+ formatJSONToHTML: async function(jsonData) {
+ console.log("inside formatJSONToHTML")
+ console.log(jsonData)
+ let html = '';
+ for (const key in jsonData) {
+ html += `- ${key} : `;
+ if (typeof jsonData[key] === 'object') {
+ html += await this.formatJSONToHTML(jsonData[key]);
+ } else{
+ html += jsonData[key];
+ }
+ html += '
';
+ }
+ html += '
';
+ console.log("format json to html: ", html)
+ return html;
+ },
getLNURLData: async function(data) {
this.lnurlData = await this.getResponseData(data)
- // console.log(" lnurl response: ", this.lnurlData)
+ console.log(" lnurl response: ", this.lnurlData)
},
getLNAddressData: async function(data) {
this.lnaddressData = await this.getResponseData(data)
// console.log('ln address response: ', this.lnaddressData)
},
+ getInvoiceData: async function(data) {
+ this.invoiceData = await this.formatJSONToHTML(data)
+ // this.invoiceData = ' foo bar baz '
+ console.log("getInvoiceData: ", data)
+ console.log("invoice data: ", this.invoiceData)
+ },
decoderFunction: async function (data) {
LNbits.api
.request(
@@ -240,6 +248,9 @@
this.invoice = this.input
this.lnurl = ''
this.lnurlData = ''
+ console.log("response.data: ", response.data)
+ console.log("response.stringify: ", JSON.stringify(response.data))
+ this.getInvoiceData(response.data)
}
})
.catch(error => {