/** @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 = "