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 + '' + "

" + "" + "" + '

'