From 17fa1c624c4b8bb45fcf15a4c187702fc31d2872 Mon Sep 17 00:00:00 2001 From: Arc <33088785+arcbtc@users.noreply.github.com> Date: Tue, 21 Jan 2020 14:10:44 +0000 Subject: [PATCH] Update app.js --- lnbits/static/app.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lnbits/static/app.js b/lnbits/static/app.js index 56a896d4..63a658a0 100644 --- a/lnbits/static/app.js +++ b/lnbits/static/app.js @@ -253,23 +253,34 @@ function scanQRsend() { var code = jsQR(imageData.data, imageData.width, imageData.height, { inversionAttempts: 'dontInvert' }) - if (code) { + if (code) { outputMessage.hidden = true outputData.parentElement.hidden = false outputData.innerText = JSON.stringify(code.data) - theinvoice = decode(code.data) - outmemo = theinvoice.data.tags[1].value - if (outmemo.split(":")[0] == "lightning") { - outmemo = outmemo.split(":")[1]; + outstr = "" + outmemo = "" + if (code.data.split(":")[0] == "lightning") { + theinvoice = decode(code.data.split(":")[1]) + outmemo = theinvoice.data.tags[1].value + outstr = JSON.stringify(code.data.split(":")[1]) } - if (outmemo.substring(0, 4).toUpperCase() == "LNBC"){ + + if (code.data.substring(0, 4).toUpperCase() != "LNBC"){ document.getElementById('sendfunds2').innerHTML = "
" + "

Not a lightning invoice

" + "" + '

' } + else{ + + theinvoice = decode(code.data) + outmemo = theinvoice.data.tags[1].value + outstr = JSON.stringify(code.data) + } + + outamount = Number(theinvoice.human_readable_part.amount) / 1000 if (outamount > Number(wallet.balance)) { document.getElementById('sendfunds2').innerHTML = @@ -286,10 +297,10 @@ function scanQRsend() { outmemo + '' + "

" + "" + "" + '

'