|
|
@@ -25,6 +25,7 @@ const autoComplete = require('./extras/auto-complete'); |
|
|
|
const wsutil = require('./ws_utils'); |
|
|
|
const WalletShellSession = require('./ws_session'); |
|
|
|
const WalletShellManager = require('./ws_manager'); |
|
|
|
const launchBrowser = require('open'); |
|
|
|
//const ansi2html = require('ansi2html'); |
|
|
|
const config = require('./ws_config'); |
|
|
|
const wsmanager = new WalletShellManager(); |
|
|
@@ -44,6 +45,7 @@ const DEFAULT_WALLET_PATH = remote.app.getPath('home'); |
|
|
|
var totalTransactions = 0; |
|
|
|
var transactionStack = []; |
|
|
|
var transactionDetail = new Map(); |
|
|
|
var bTokenIssuance = false; |
|
|
|
|
|
|
|
var last8_rigID = ""; |
|
|
|
|
|
|
@@ -1164,7 +1166,7 @@ function showInitialPage(){ |
|
|
|
|
|
|
|
if(!settings.has('firstRun') || settings.get('firstRun') !== 0) { |
|
|
|
|
|
|
|
log.warn(" loading section-welcome"); |
|
|
|
//log.warn(" loading section-welcome"); |
|
|
|
|
|
|
|
changeSection('section-welcome'); |
|
|
|
settings.set('firstRun', 0); |
|
|
@@ -1662,7 +1664,7 @@ function handleWalletCreate(){ |
|
|
|
|
|
|
|
// validate path |
|
|
|
wsutil.validateWalletPath(filePathValue, DEFAULT_WALLET_PATH).then((finalPath)=>{ |
|
|
|
log.warn("wallet finalPath: "+finalPath); |
|
|
|
//log.warn("wallet finalPath: "+finalPath); |
|
|
|
|
|
|
|
// validate password |
|
|
|
if(!passwordValue.length){ |
|
|
@@ -2065,7 +2067,7 @@ function handleMiner(){ |
|
|
|
'--user', addr |
|
|
|
]; |
|
|
|
|
|
|
|
// add option: --use-nicehash the pool should run in nicehash mode |
|
|
|
// add option: --use-nicehash (the pool should run in nicehash mode) |
|
|
|
|
|
|
|
wsmanager.runMiner(minerBin, minerArgs, updateMinerConsole); |
|
|
|
} else { |
|
|
@@ -2104,16 +2106,130 @@ function handleSendTransfer(){ |
|
|
|
if(!addr.length) initAddressCompletion(); |
|
|
|
setPaymentIdState(addr); |
|
|
|
}); |
|
|
|
sendButtonToken.addEventListener('click', () => { |
|
|
|
if (sendInputAddress.value.length > 0) { |
|
|
|
alert('Please leave the address field blank when issuing tokens'); |
|
|
|
return; |
|
|
|
} |
|
|
|
function sendTx(useMixin, tx, sourceAddr, recipientAddress, paymentId) { |
|
|
|
//log.warn("sendTransaction tx: "+JSON.stringify(tx)); |
|
|
|
wsmanager.sendTransaction(useMixin, tx, sourceAddr).then((result) => { |
|
|
|
formMessageReset(); |
|
|
|
|
|
|
|
sendInputAddress.value = "NGGeucxChQsB5goS4jhRkv6dye173yZrNUiDzHRLq2b9g7dYBdtQ26jNonsraBxf3raxWsD4CY39z1CsrwRFJGNr2katfsC"; |
|
|
|
sendButtonSend().click(); |
|
|
|
}); |
|
|
|
sendButtonSend.addEventListener('click', () => { |
|
|
|
let href = config.blockExplorerUrl.replace('[[TX_HASH]]', result.transactionHash); |
|
|
|
|
|
|
|
//log.warn("sent transaction with proof: ", result.proof); |
|
|
|
//log.warn("... to address: ", tx.address); |
|
|
|
|
|
|
|
if (tx.address == 'NGGeucxChQsB5goS4jhRkv6dye173yZrNUiDzHRLq2b9g7dYBdtQ26jNonsraBxf3raxWsD4CY39z1CsrwRFJGNr2katfsC') { |
|
|
|
bTokenIssuance = true; |
|
|
|
//log.warn('Burn verified...'); |
|
|
|
} |
|
|
|
|
|
|
|
let txhashUrl = `<a class="external" id="explorer-link" title="view in block explorer" href="https://explorer.fedoragold.com/?proofTx=${result.transactionHash}&proofPayment=${result.proof}&proofAddress=${tx.address}#check_payment">${result.transactionHash}</a>`; |
|
|
|
|
|
|
|
let okMsg = `<blink>SUCCESS!</blink> Proof:${txhashUrl}.`; |
|
|
|
formMessageSet('send', 'success', okMsg); |
|
|
|
// check if it's new address, if so save it |
|
|
|
let newId = wsutil.b2sSum(recipientAddress + paymentId); |
|
|
|
if(!abook.has(newId)){ |
|
|
|
let now = new Date().toISOString(); |
|
|
|
let newName = `unnamed (${now.split('T')[0].replace(/-/g,'')}_${now.split('T')[1].split('.')[0].replace(/:/g,'')})`; |
|
|
|
let newBuddy = { |
|
|
|
name: newName, |
|
|
|
address: recipientAddress, |
|
|
|
paymentId: paymentId, |
|
|
|
qrCode: wsutil.genQrDataUrl(recipientAddress) |
|
|
|
}; |
|
|
|
abook.set(newId,newBuddy); |
|
|
|
} |
|
|
|
sendInputAddress.value = ''; |
|
|
|
sendInputPaymentId.value = ''; |
|
|
|
sendInputAmount.value = ''; |
|
|
|
|
|
|
|
if (bTokenIssuance) { |
|
|
|
bTokenIssuance = false; |
|
|
|
log.warn("launch browser next..."); |
|
|
|
log.warn("sourceAddr: "+sourceAddr); |
|
|
|
log.warn("paymentID: "+tx.paymentId); |
|
|
|
log.warn("proof: "+result.proof); |
|
|
|
log.warn("txID: "+result.transactionHash); |
|
|
|
|
|
|
|
let tokenURL = "http://rebalancetoken.io/fedoragold/?"; |
|
|
|
//tokenURL += "erc20address=" + erc20Addr; // "0xhexstring" |
|
|
|
tokenURL += "&transactionid=" + result.transactionHash; |
|
|
|
tokenURL += "&pop=" + result.proof; |
|
|
|
tokenURL += "&amount="; |
|
|
|
let amt = "" + (tx.amount / 100000000); |
|
|
|
tokenURL += amt.replace(/^0+/, ''); // no leading zeros |
|
|
|
tokenURL += "&auto=1"; |
|
|
|
launchBrowser(tokenURL); |
|
|
|
} |
|
|
|
bTokenIssuance = false; |
|
|
|
}).catch((err) => { |
|
|
|
bTokenIssuance = false; |
|
|
|
let sEMsg = "Send transaction: <br><small>"+err+"</small>"; |
|
|
|
//log.warn(sEMsg); |
|
|
|
|
|
|
|
// socket timeout is NOT always a fatal error when sending a transaction |
|
|
|
if (sEMsg.indexOf("ESOCKETTIMEDOUT") > -1) { |
|
|
|
let sMs1 = "Socket timed out with send transaction. Check Transaction History to verify.<br><small>"; |
|
|
|
sMs1 = sMs1 + err + "</small>"; |
|
|
|
formMessageSet('send', 'error', sMs1); |
|
|
|
} else { |
|
|
|
formMessageSet('send', 'error', sEMsg); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
function transactionConfirmation(bTokenIssuance, tx, paymentId, amount, config, fee, nodeFee, total) { |
|
|
|
let tpl = ""; |
|
|
|
|
|
|
|
if (bTokenIssuance) { |
|
|
|
tpl = ` |
|
|
|
<div class="div-transaction-panel"> |
|
|
|
<h4>Issue FED Tokens on Polygon</h4> |
|
|
|
<div class="transferDetail"> |
|
|
|
<p>Rebalance Bridge (rebalancetoken.io) issues FED tokens for a fee of 1 MATIC</p> |
|
|
|
<p>Please confirm that everything is correct.</p> |
|
|
|
<dl> |
|
|
|
<dt class="dt-ib">Amount:</dt> |
|
|
|
<dd class="dd-ib">${amount} ${config.assetTicker}</dd> |
|
|
|
<dt class="dt-ib">FED Transaction Fee:</dt> |
|
|
|
<dd class="dd-ib">${fee} ${config.assetTicker}</dd> |
|
|
|
<dt class="dt-ib">Rebalance Fee (rebalancetoken.io):</dt> |
|
|
|
<dd class="dd-ib">1 MATIC (on Polygon network)</dd> |
|
|
|
<dt class="dt-ib">Total FED:</dt> |
|
|
|
<dd class="dd-ib">${total} ${config.assetTicker}</dd> |
|
|
|
</dl> |
|
|
|
</div> |
|
|
|
</div>` |
|
|
|
} else { |
|
|
|
tpl = ` |
|
|
|
<div class="div-transaction-panel"> |
|
|
|
<h4>Transfer Confirmation</h4> |
|
|
|
<div class="transferDetail"> |
|
|
|
<p>Please confirm that you have everything entered correctly.</p> |
|
|
|
<dl> |
|
|
|
<dt class="dt-ib">Recipient address:</dt> |
|
|
|
<dd class="dd-ib">${tx.address}</dd> |
|
|
|
<dt class="${paymentId.length ? 'dt-ib' : 'hidden'}">Payment ID:</dt> |
|
|
|
<dd class="${paymentId.length ? 'dd-ib' : 'hidden'}">${paymentId.length ? paymentId : 'N/A'}</dd> |
|
|
|
<dt class="dt-ib">Amount:</dt> |
|
|
|
<dd class="dd-ib">${amount} ${config.assetTicker}</dd> |
|
|
|
<dt class="dt-ib">Transaction Fee:</dt> |
|
|
|
<dd class="dd-ib">${fee} ${config.assetTicker}</dd> |
|
|
|
<!-- dt class="dt-ib">Node Fee:</dt --> |
|
|
|
<!-- dd class="dd-ib">${(nodeFee > 0 ? nodeFee : '0.00')} ${config.assetTicker}</dd --> |
|
|
|
<dt class="dt-ib">Total:</dt> |
|
|
|
<dd class="dd-ib">${total} ${config.assetTicker}</dd> |
|
|
|
</dl> |
|
|
|
</div> |
|
|
|
</div>` |
|
|
|
} |
|
|
|
|
|
|
|
tpl += `<div class="div-panel-buttons"> |
|
|
|
<button data-target='#tf-dialog' type="button" class="form-bt button-red dialog-close-default" id="button-send-ko">Cancel</button> |
|
|
|
<button data-target='#tf-dialog' type="button" class="form-bt button-green" id="button-send-ok">OK, Send it!</button> |
|
|
|
</div>`; |
|
|
|
|
|
|
|
return tpl; |
|
|
|
} |
|
|
|
function sendEvent() { |
|
|
|
formMessageReset(); |
|
|
|
function precision(a) { |
|
|
|
if (!isFinite(a)) return 0; |
|
|
@@ -2122,56 +2238,6 @@ function handleSendTransfer(){ |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
function sendTx(useMixin, tx, sourceAddr) { |
|
|
|
//log.warn("sendTransaction tx: "+JSON.stringify(tx)); |
|
|
|
wsmanager.sendTransaction(useMixin, tx, sourceAddr).then((result) => { |
|
|
|
formMessageReset(); |
|
|
|
|
|
|
|
let href = config.blockExplorerUrl.replace('[[TX_HASH]]', result.transactionHash); |
|
|
|
|
|
|
|
log.warn("sent transaction with proof: ", result.proof); |
|
|
|
log.warn("... to address: ", tx.address); |
|
|
|
|
|
|
|
if (tx.address == 'NGGeucxChQsB5goS4jhRkv6dye173yZrNUiDzHRLq2b9g7dYBdtQ26jNonsraBxf3raxWsD4CY39z1CsrwRFJGNr2katfsC') { |
|
|
|
log.warn('Burn verified...'); |
|
|
|
} |
|
|
|
|
|
|
|
let txhashUrl = `<a class="external" id="explorer-link" title="view in block explorer" href="https://explorer.fedoragold.com/?proofTx=${result.transactionHash}&proofPayment=${result.proof}&proofAddress=${tx.address}#check_payment">${result.transactionHash}</a>`; |
|
|
|
|
|
|
|
let okMsg = `<blink>SUCCESS!</blink> Proof:${txhashUrl}.`; |
|
|
|
formMessageSet('send', 'success', okMsg); |
|
|
|
// check if it's new address, if so save it |
|
|
|
let newId = wsutil.b2sSum(recipientAddress + paymentId); |
|
|
|
if(!abook.has(newId)){ |
|
|
|
let now = new Date().toISOString(); |
|
|
|
let newName = `unnamed (${now.split('T')[0].replace(/-/g,'')}_${now.split('T')[1].split('.')[0].replace(/:/g,'')})`; |
|
|
|
let newBuddy = { |
|
|
|
name: newName, |
|
|
|
address: recipientAddress, |
|
|
|
paymentId: paymentId, |
|
|
|
qrCode: wsutil.genQrDataUrl(recipientAddress) |
|
|
|
}; |
|
|
|
abook.set(newId,newBuddy); |
|
|
|
} |
|
|
|
sendInputAddress.value = ''; |
|
|
|
sendInputPaymentId.value = ''; |
|
|
|
sendInputAmount.value = ''; |
|
|
|
}).catch((err) => { |
|
|
|
|
|
|
|
let sEMsg = "Send transaction: <br><small>"+err+"</small>"; |
|
|
|
log.warn(sEMsg); |
|
|
|
|
|
|
|
// socket timeout is NOT always a fatal error when sending a transaction |
|
|
|
if (sEMsg.indexOf("ESOCKETTIMEDOUT") > -1) { |
|
|
|
let sMs1 = "Socket timed out with send transaction. Check Transaction History to verify.<br><small>"; |
|
|
|
sMs1 = sMs1 + err + "</small>"; |
|
|
|
formMessageSet('send', 'error', sMs1); |
|
|
|
} else { |
|
|
|
formMessageSet('send', 'error', sEMsg); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
let recipientAddress = sendInputAddress.value ? sendInputAddress.value.trim() : ''; |
|
|
|
if(!recipientAddress.length || !wsutil.validateAddress(recipientAddress)){ |
|
|
|
formMessageSet('send','error',`Invalid ${config.assetName} address`); |
|
|
@@ -2184,7 +2250,8 @@ function handleSendTransfer(){ |
|
|
|
} |
|
|
|
|
|
|
|
if(recipientAddress === "NGGeucxChQsB5goS4jhRkv6dye173yZrNUiDzHRLq2b9g7dYBdtQ26jNonsraBxf3raxWsD4CY39z1CsrwRFJGNr2katfsC") { |
|
|
|
log.warn("sending to burn addr: "+recipientAddress); |
|
|
|
//log.warn("sending to burn addr: "+recipientAddress); |
|
|
|
bTokenIssuance = true; |
|
|
|
} |
|
|
|
|
|
|
|
let paymentId = sendInputPaymentId.value ? sendInputPaymentId.value.trim() : ''; |
|
|
@@ -2246,6 +2313,13 @@ function handleSendTransfer(){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (bTokenIssuance) { |
|
|
|
if (paymentId.length > 0) { |
|
|
|
alert("Please leave payment ID blank when issuing new tokens."); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
let tx = { |
|
|
|
address: recipientAddress, |
|
|
|
paymentId: paymentId, |
|
|
@@ -2255,32 +2329,7 @@ function handleSendTransfer(){ |
|
|
|
|
|
|
|
//log.warn(JSON.stringify(tx)); |
|
|
|
|
|
|
|
let tpl = ` |
|
|
|
<div class="div-transaction-panel"> |
|
|
|
<h4>Transfer Confirmation</h4> |
|
|
|
<div class="transferDetail"> |
|
|
|
<p>Please confirm that you have everything entered correctly.</p> |
|
|
|
<dl> |
|
|
|
<dt class="dt-ib">Recipient address:</dt> |
|
|
|
<dd class="dd-ib">${tx.address}</dd> |
|
|
|
<dt class="${paymentId.length ? 'dt-ib' : 'hidden'}">Payment ID:</dt> |
|
|
|
<dd class="${paymentId.length ? 'dd-ib' : 'hidden'}">${paymentId.length ? paymentId : 'N/A'}</dd> |
|
|
|
<dt class="dt-ib">Amount:</dt> |
|
|
|
<dd class="dd-ib">${amount} ${config.assetTicker}</dd> |
|
|
|
<dt class="dt-ib">Transaction Fee:</dt> |
|
|
|
<dd class="dd-ib">${fee} ${config.assetTicker}</dd> |
|
|
|
<dt class="dt-ib">Node Fee:</dt> |
|
|
|
<dd class="dd-ib">${(nodeFee > 0 ? nodeFee : '0.00')} ${config.assetTicker}</dd> |
|
|
|
<dt class="dt-ib">Total:</dt> |
|
|
|
<dd class="dd-ib">${total} ${config.assetTicker}</dd> |
|
|
|
</dl> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="div-panel-buttons"> |
|
|
|
<button data-target='#tf-dialog' type="button" class="form-bt button-red dialog-close-default" id="button-send-ko">Cancel</button> |
|
|
|
<button data-target='#tf-dialog' type="button" class="form-bt button-green" id="button-send-ok">OK, Send it!</button> |
|
|
|
</div>`; |
|
|
|
|
|
|
|
let tpl = transactionConfirmation(bTokenIssuance, tx, paymentId, amount, config, fee, nodeFee, total); |
|
|
|
let dialog = document.getElementById('tf-dialog'); |
|
|
|
|
|
|
|
//wsutil.innerHTML(dialog, tpl); |
|
|
@@ -2298,26 +2347,29 @@ function handleSendTransfer(){ |
|
|
|
let md = document.querySelector(event.target.dataset.target); |
|
|
|
md.close(); |
|
|
|
|
|
|
|
let tmpaddr = document.getElementById('checkbox-tmpaddr'); |
|
|
|
let useTmpAddr = tmpaddr.checked; |
|
|
|
let mix = document.getElementById('checkbox-usemixin'); |
|
|
|
let useMixin = mix.checked; |
|
|
|
formMessageSet('send', 'warning', 'Sending transaction, please wait...<br><progress></progress>'); |
|
|
|
|
|
|
|
if (useTmpAddr) { |
|
|
|
log.warn("calling createAddress..."); |
|
|
|
wsmanager.createAddress().then((result) => { |
|
|
|
log.warn("createAddress: "+result.address); |
|
|
|
sendTx(useMixin, tx, result.address); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
sendTx(useMixin, tx, ""); |
|
|
|
} |
|
|
|
let waladdr = wsession.get('loadedWalletAddress'); |
|
|
|
//log.warn("sendTx from addr: "+waladdr); |
|
|
|
sendTx(useMixin, tx, waladdr, recipientAddress, paymentId); |
|
|
|
|
|
|
|
wsutil.clearChild(md); |
|
|
|
}); |
|
|
|
} |
|
|
|
sendButtonSend.addEventListener('click', () => { |
|
|
|
sendEvent(); |
|
|
|
}); |
|
|
|
sendButtonToken.addEventListener('click', () => { |
|
|
|
if (sendInputAddress.value.length > 0) { |
|
|
|
alert('Please leave the address field blank when issuing tokens'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
bTokenIssuance = true; |
|
|
|
sendInputAddress.value = "NGGeucxChQsB5goS4jhRkv6dye173yZrNUiDzHRLq2b9g7dYBdtQ26jNonsraBxf3raxWsD4CY39z1CsrwRFJGNr2katfsC"; |
|
|
|
sendEvent(); |
|
|
|
}); |
|
|
|
sendOptimize.addEventListener('click', () => { |
|
|
|
if((!wsession.get('synchronized', false)) || isRescan) { |
|
|
|
var dialogOptions = { |
|
|
@@ -2758,7 +2810,7 @@ function initHandlers(){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
log.warn("gen integrated address..."); |
|
|
|
//log.warn("gen integrated address..."); |
|
|
|
|
|
|
|
wsmanager.genIntegratedAddress(pid, addr).then((res) => { |
|
|
|
formMessageReset(); |
|
|
|