/** @format */ const user = window.user const user_wallets = window.user_wallets const wallet = window.wallet const transactions = window.transactions var thehash = '' var theinvoice = '' var outamount = '' var outmemo = '' // API CALLS function postAjax(url, data, thekey, success) { var params = typeof data == 'string' ? data : Object.keys(data) .map(function(k) { return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) }) .join('&') var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP') xhr.open('POST', url) xhr.onreadystatechange = function() { if (xhr.readyState > 3 && xhr.status == 200) { success(xhr.responseText) } } xhr.setRequestHeader('Grpc-Metadata-macaroon', thekey) xhr.setRequestHeader('Content-Type', 'application/json') xhr.send(params) return xhr } function getAjax(url, thekey, success) { var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP') xhr.open('GET', url, true) xhr.onreadystatechange = function() { if (xhr.readyState > 3 && xhr.status == 200) { success(xhr.responseText) } } xhr.setRequestHeader('Grpc-Metadata-macaroon', thekey) xhr.setRequestHeader('Content-Type', 'application/json') xhr.send() return xhr } function sendfundsinput() { document.getElementById('sendfunds').innerHTML = "' } } function receive() { document.getElementById('receive').innerHTML = "" document.getElementById('sendfunds').innerHTML = '' } function received() { memo = document.getElementById('memo').value amount = document.getElementById('amount').value postAjax( '/api/v1/invoices', JSON.stringify({value: amount, memo: memo}), wallet.inkey, function(data) { theinvoice = JSON.parse(data).pay_req thehash = JSON.parse(data).payment_hash document.getElementById('QRCODE').innerHTML = "
' new QRCode(document.getElementById('qrcode'), { text: theinvoice, width: 300, height: 300, colorDark: '#000000', colorLight: '#ffffff', correctLevel: QRCode.CorrectLevel.M }) document.getElementById("qrcode").style.backgroundColor = "white"; document.getElementById("qrcode").style.padding = "20px"; setInterval(function(){ getAjax('/api/v1/invoice/' + thehash, wallet.inkey, function(datab) { console.log(JSON.parse(datab).PAID) if (JSON.parse(datab).PAID == 'TRUE') { window.location.href = 'wallet?wal=' + wallet.id + '&usr=' + user } })}, 3000); } ) } function cancelsend() { window.location.href = 'wallet?wal=' + wallet.id + '&usr=' + user } function processing() { document.getElementById('processing').innerHTML = "" window.top.location.href = "lnurlwallet?lightning=" + getQueryVariable("lightning"); } function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;iProcessing...<


'; postAjax( '/api/v1/channels/transactions', JSON.stringify({payment_request: invoice}), wallet.adminkey, function(data) { thehash = JSON.parse(data).payment_hash setInterval(function(){ getAjax('/api/v1/payment/' + thehash, wallet.adminkey, function(datab) { console.log(JSON.parse(datab).PAID) if (JSON.parse(datab).PAID == 'TRUE') { window.location.href = 'wallet?wal=' + wallet.id + '&usr=' + user } })}, 3000); } ) } function scanQRsend() { document.getElementById('sendfunds2').innerHTML = "