diff --git a/assets/scripts/atomicexplorer.js b/assets/scripts/atomicexplorer.js index 3520a57..b59dfab 100644 --- a/assets/scripts/atomicexplorer.js +++ b/assets/scripts/atomicexplorer.js @@ -2,7 +2,7 @@ var AtomicExplorer = function() { toastr.options = { 'closeButton': true, 'debug': false, - 'positionClass': 'toast-top-right', + 'positionClass': 'toast-bottom-right', 'showDuration': '5000', 'hideDuration': '1000', 'timeOut': '5000', @@ -272,6 +272,15 @@ var AtomicExplorer = function() { 'timeout': 600000 }; break; + case 'dex_sendrawtransaction': + ExplorerInputData = { + 'userpass': tmpIguanaRPCAuth, + 'agent': 'dex', + 'method': 'sendrawtransaction', + 'signedtx': atomic_explorer_input_data_val, + 'symbol': atomic_explorer_select_coin_val + }; + break; case 'basilisk_refresh': ExplorerInputData = { 'userpass': tmpIguanaRPCAuth, @@ -293,6 +302,7 @@ var AtomicExplorer = function() { console.log(data); if (atomic_explorer_select_command_val === 'txid' || atomic_explorer_select_command_val === 'dex_getbestblockhash' || + atomic_explorer_select_command_val === 'dex_sendrawtransaction' || atomic_explorer_select_command_val === 'dex_getblockhash') { $('#atomic-explorer-commands-output').html(data); } else { diff --git a/assets/scripts/dashboard.js b/assets/scripts/dashboard.js index cd9e619..8dc5759 100644 --- a/assets/scripts/dashboard.js +++ b/assets/scripts/dashboard.js @@ -9,7 +9,7 @@ var Dashboard = function() { toastr.options = { 'closeButton': true, 'debug': false, - 'positionClass': 'toast-top-right', + 'positionClass': 'toast-bottom-right', 'showDuration': '15000', 'hideDuration': '1000', 'timeOut': '15000', @@ -126,12 +126,12 @@ var Dashboard = function() { $('#btn_edexcoin_dashboard').show(); $('#btn_edexcoin_send').hide(); $('#btn_edexcoin_recieve').show(); - sessionStorage.setItem('edexTmpRefresh', 'stop'); $('#edexcoin_dashboardinfo').hide(); $('#edexcoin_send').show(); $('#edexcoin_recieve').hide(); $('#edexcoin_recieve_section').hide(); $('#edexcoin_settings').hide(); + sessionStorage.setItem('edexTmpRefresh', 'stop'); var active_edexcoin = $('[data-edexcoin]').attr('data-edexcoin'); var selected_coinmode = sessionStorage.getItem('edexTmpMode') @@ -179,11 +179,29 @@ var Dashboard = function() { $('#edexcoin_send_from').change(function() { if ($('#edexcoin_send_from').val() !== '' || $('#edexcoin_send_from').val() !== '- Select Address -') { $('.edexcoin_send_coins_btn_step1').removeClass('disabled'); - $('.edexcoin_send_coins_btn_step1').removeAttr('disabled'); + $('.edexcoin_send_coins_btn_step1').prop('disabled', false); + + Shepherd_GetBasiliskCache().then(function(result){ + var _data = JSON.parse(result) + query = _data.result.basilisk + active_edexcoin = $('[data-edexcoin]').attr('data-edexcoin'); + coin_addr = $('#edexcoin_send_from').val() + + if (!('refresh' in query[active_edexcoin][coin_addr])) { + console.log(active_edexcoin + '>>>' + coin_addr + ' => refresh not found.') + + var call_data = {"allcoins": false,"coin":active_edexcoin,"calls":"refresh"} + Shepherd_FetchBasiliskData(call_data).then(function(result){ + console.log(result) + }) + } else { + console.log(query[active_edexcoin][coin_addr].refresh.status) + } + }) } if ($('#edexcoin_send_from').val() === '' || $('#edexcoin_send_from').val() === '- Select Address -') { $('.edexcoin_send_coins_btn_step1').addClass(' disabled'); - $('.edexcoin_send_coins_btn_step1').attr('disabled','disabled'); + $('.edexcoin_send_coins_btn_step1').prop('disabled', true); } }) @@ -300,16 +318,20 @@ var Dashboard = function() { }); $('#edexcoin_send_coins_btn').click(function() { - $('#edexcoin_send_coins_btn').prop('disabled', true); + //$('#edexcoin_send_coins_btn').prop('disabled', true); console.log('==> After confirming tx to send') var active_edexcoin = $('[data-edexcoin]').attr('data-edexcoin'), tmp_send_from_addr = $('#edexcoin_send_from').val() tmp_send_to_addr = $('#edexcoin_sendto').val(), tmp_send_total_amount = $('#edexcoin_total_value').text(); + tmp_send_fee = $('#edexcoin_fee').val() + tmp_sendflag = $('#edexcoin_send_sig').is(":checked") console.log(active_edexcoin); console.log(tmp_send_from_addr); console.log(tmp_send_to_addr); console.log(tmp_send_total_amount); + console.log(tmp_send_fee); + console.log(tmp_sendflag); var edexcoin_sendto_result_tbl = ''; edexcoin_sendto_result_tbl += '' + @@ -319,17 +341,34 @@ var Dashboard = function() { $('#edexcoin_sendto_result tbody').html(edexcoin_sendto_result_tbl); $('#edexcoin_send_coins_anothertx_btn').hide(); - var tmp_json_data = { - 'coin': active_edexcoin, - 'sendtoaddr': tmp_send_to_addr, - 'amount': tmp_send_total_amount - }; - console.log(tmp_json_data); - EDEXSendToAddr(tmp_json_data); + var active_edexcoin = $('[data-edexcoin]').attr('data-edexcoin'); + var selected_coinmode = sessionStorage.getItem('edexTmpMode') + + if (selected_coinmode == 'Basilisk' && active_edexcoin !== 'BTC' && active_edexcoin !== 'SYS' ) { + var tmp_json_data = { + 'coin': active_edexcoin, + 'sendfrom': tmp_send_from_addr, + 'sendtoaddr': tmp_send_to_addr, + 'amount': tmp_send_total_amount, + 'txfee': tmp_send_fee, + 'sendsig': tmp_sendflag + }; + console.log(tmp_json_data); + EDEXSendutxoRawTx(tmp_json_data) + } else { + var tmp_json_data = { + 'coin': active_edexcoin, + 'sendtoaddr': tmp_send_to_addr, + 'amount': tmp_send_total_amount + }; + console.log(tmp_json_data); + EDEXSendToAddr(tmp_json_data); + } $('.edexcoin-send-form')[0].reset(); $('#edexcoin_total_value').text('0.000'); $('#edexcoin-send-confirm-screen').hide(); $('#edexcoin-send-txdetails-screen').show(); + $('#edexcoin-send-txdetails-screen').data('panel-api').load(); edexcoin_send_form_validator.resetForm(); $('#edexcoin_send_step_1').removeClass( 'current' ).addClass( '' ); $('#edexcoin_send_step_2').removeClass( 'current' ).addClass( '' ); @@ -737,17 +776,19 @@ var Dashboard = function() { }, 1000); - var CheckIfIguanaRunning = setInterval(function() { + var FetchBasiliskData = setInterval(function() { // TODO: refactor if ( sessionStorage.getItem('IguanaActiveAccount') === null ) { - //clearInterval(CheckIfIguanaRunning); + //clearInterval(FetchBasiliskData); //console.log('=> No wallet logged in, or Dashboard not ative. No need to Run History.'); } else { if ( active_edexcoinmodecode == 'Basilisk') { var call_data = {"allcoins": false,"coin":active_edexcoin,"calls":"listtransactions:getbalance"} - Shepherd_FetchBasiliskData(call_data).then(function(result){ - console.log(result) - }) + if ( sessionStorage.getItem('edexTmpRefresh') === null || sessionStorage.getItem('edexTmpRefresh') === 'start') { + Shepherd_FetchBasiliskData(call_data).then(function(result){ + console.log(result) + }) + } } } }, 300000); @@ -1211,7 +1252,7 @@ function getDEXGetBalance_cache(coin) { var call_data = { 'allcoins': false, 'coin': coin, - 'calls': 'listtransactions:getbalance' + 'calls': 'listtransactions:getbalance:refresh' }; //console.log(call_data) Shepherd_FetchBasiliskData(call_data).then(function(result) { @@ -1898,7 +1939,7 @@ function EdexGetTxList(coin) { params = { 'userpass': tmpIguanaRPCAuth, 'agent': 'dex', - 'method': 'listtransactions2', + 'method': 'listtransactions', 'address': coinaddr_value, 'count': 100, 'skip': 0, @@ -2197,7 +2238,7 @@ function EdexGetTxList_cache(coin) { || coin == 'FRK') { var ajax_data_2 = {'userpass':tmpIguanaRPCAuth,"agent":"dex","method":"listtransactions","address":data[coin],"count":100,"skip":0,"symbol":coin} } else { - var ajax_data_2 = {'userpass':tmpIguanaRPCAuth,"agent":"dex","method":"listtransactions2","address":data[coin],"count":100,"skip":0,"symbol":coin} + var ajax_data_2 = {'userpass':tmpIguanaRPCAuth,"agent":"dex","method":"listtransactions","address":data[coin],"count":100,"skip":0,"symbol":coin} } } else { var ajax_data_2 = {'userpass':tmpIguanaRPCAuth,"coin":coin,"method":"listtransactions","params":[0, 9999999, []]} @@ -2679,7 +2720,7 @@ function ShowBasiliskFetchDataProgress(coin) { BasiliskFetchData += ''; $('.tbl_edexcoin_dashboard_basilisk_refresh_status tbody').html(BasiliskFetchData); - if (result[result.length-1] == result_val && result_val.listtransactions_status !== 'done' && result_val.getbalance_status !== 'done' ) { + if (result[result.length-1] == result_val && result_val.listtransactions_status !== 'done' && result_val.getbalance_status !== 'done' && result_val.refresh_status !== 'done' ) { $('#edexcoin_dashboard_basilisk_refresh_status').show() } else { $('#edexcoin_dashboard_basilisk_refresh_status').hide() diff --git a/assets/scripts/iguana_api.js b/assets/scripts/iguana_api.js index fe2fc74..ffc3699 100644 --- a/assets/scripts/iguana_api.js +++ b/assets/scripts/iguana_api.js @@ -140,19 +140,25 @@ function Iguana_activehandle(callback) { 'userpass': tmpIguanaRPCAuth, 'agent': 'SuperNET', 'method': 'activehandle' - }, - AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) { - AjaxOutputData = JSON.parse(AjaxOutputData.responseText); - resolve(AjaxOutputData); - }).fail(function(xhr, textStatus, error) { - // handle request failures - console.log(xhr.statusText); - if ( xhr.readyState == 0 ) { - Iguana_ServiceUnavailable(); - } - console.log(textStatus); - console.log(error); - }); + }; + + $.ajax({ + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + type: 'POST', + dataType: 'json' + }).then(result => { + //console.log(result); + resolve(result); + }).fail(function(xhr, textStatus, error) { + // handle request failures + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + }); }); } @@ -1183,6 +1189,165 @@ function EDEXgetBalance(coin) { return result; } +function EDEXSendutxoRawTx(data) { + Shepherd_GetBasiliskCache().then(function(result){ + var _data = JSON.parse(result) + query = _data.result.basilisk + utxos_set = query[data.coin][data.sendfrom].refresh.data + + send_data = { + 'coin': data.coin, + 'sendfrom': data.sendfrom, + 'sendtoaddr': data.sendtoaddr, + 'amount': data.amount, + 'txfee': data.txfee, + 'sendsig': (data.sendsig == true ? 0 : 1 ), + 'utxos': utxos_set + }; + //console.log(send_data) + Iguana_utxorawtx(send_data).then(function(result){ + console.log(result); + var edexcoin_sendto_result_tbl = ''; + + if (result.result == 'success') { + console.log(send_data) + toastr.success('Signed transaction generated.', 'Wallet Notification'); + } + if (send_data.sendsig == 1) { + console.log(send_data) + toastr.info('Sending Transaction to Network.', 'Wallet Notification'); + ajax_data_dexrawtx = { + 'signedtx': result.signedtx, + 'coin': send_data.coin + }; + Iguana_DEXsendrawtx(ajax_data_dexrawtx).then(function(dexrwatx_result){ + console.log(dexrwatx_result); + if (dexrwatx_result.error == undefined) { + var active_edexcoin = $('[data-edexcoin]').attr('data-edexcoin'); + toastr.success('Signed transaction sent successfully!', 'Wallet Notification'); + edexcoin_sendto_result_tbl += '' + + 'result' + + '' + + '' + result.result + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'completed' + + '' + + '' + result.completed + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'rawtx' + + '' + + '' + result.rawtx + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'txid' + + '' + + '' + dexrwatx_result + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'signedtx' + + '' + + '' + result.signedtx + '' + + '' + + ''; + $('#edexcoin_sendto_result tbody').html(edexcoin_sendto_result_tbl); + $('#edexcoin_send_coins_anothertx_btn').show(); + $('#edexcoin-send-txdetails-screen').data('panel-api').done(); + + var call_data = {"allcoins": false,"coin":'KMD',"calls":"refresh"} + console.log(call_data) + Shepherd_FetchBasiliskData(call_data).then(function(result){ + console.log(result) + toastr.info('Refreshing Wallet Funds.', 'Wallet Notification'); + }) + } else { + var active_edexcoin = $('[data-edexcoin]').attr('data-edexcoin'); + toastr.success('Signed transaction sent successfully!', 'Wallet Notification'); + edexcoin_sendto_result_tbl += '' + + 'result' + + '' + + '' + dexrwatx_result.result + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'error' + + '' + + '' + dexrwatx_result.error + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'signedtx' + + '' + + '' + ajax_data_dexrawtx.signedtx + '' + + '' + + ''; + $('#edexcoin_sendto_result tbody').html(edexcoin_sendto_result_tbl); + $('#edexcoin_send_coins_anothertx_btn').show(); + $('#edexcoin-send-txdetails-screen').data('panel-api').done(); + + var call_data = {"allcoins": false,"coin":'KMD',"calls":"refresh"} + console.log(call_data) + Shepherd_FetchBasiliskData(call_data).then(function(result){ + console.log(result) + toastr.info('Refreshing Wallet Funds.', 'Wallet Notification'); + }) + } + }) + } + if (send_data.sendsig == 0) { + console.log(send_data) + var active_edexcoin = $('[data-edexcoin]').attr('data-edexcoin'); + //toastr.success('Signed Transaction Generated.', 'Wallet Notification'); + edexcoin_sendto_result_tbl += '' + + 'result' + + '' + + '' + result.result + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'completed' + + '' + + '' + result.completed + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'rawtx' + + '' + + '' + result.rawtx + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'txid' + + '' + + '' + result.txid + '' + + '' + + ''; + edexcoin_sendto_result_tbl += '' + + 'signedtx' + + '' + + '' + result.signedtx + '' + + '' + + ''; + $('#edexcoin_sendto_result tbody').html(edexcoin_sendto_result_tbl); + $('#edexcoin_send_coins_anothertx_btn').show(); + $('#edexcoin-send-txdetails-screen').data('panel-api').done(); + + var call_data = {"allcoins": false,"coin":'KMD',"calls":"refresh"} + console.log(call_data) + Shepherd_FetchBasiliskData(call_data).then(function(result){ + console.log(result) + toastr.info('Refreshing Wallet Funds.', 'Wallet Notification'); + }) + } + }) + }) +} + function EDEXSendToAddr(data) { var result = [], confirm_coinname_to_send = data.coin, @@ -2020,6 +2185,61 @@ function Iguana_DEXValidateAddr(coin, addr) { return result; } +function Iguana_utxorawtx(data) { + var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'symbol': data.coin, + 'agent': 'basilisk', + 'method': 'utxorawtx', + 'vals': { + 'timelock': 0, + 'changeaddr': data.sendfrom, + 'destaddr': data.sendtoaddr, + 'txfee': data.txfee, + 'amount': data.amount, + 'sendflag': data.sendsig + }, + 'utxos': data.utxos + }; + return new Promise((resolve) => { + console.log(ajax_data); + $.ajax({ + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + type: 'POST', + dataType: 'json' + }).then(result => { + //console.log(result); + resolve(result); + }); + }) +} + +function Iguana_DEXsendrawtx(data) { + var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': 'dex', + 'method': 'sendrawtransaction', + 'signedtx': data.signedtx, + 'symbol': data.coin + } + return new Promise((resolve) => { + console.log(ajax_data); + $.ajax({ + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + type: 'POST', + dataType: 'json' + }).then(result => { + console.log(result); + resolve(result); + }); + }) + +} + function EDEX_DEXlistunspent(coin, addr) { NProgress.done(true); NProgress.configure({ diff --git a/assets/scripts/login.js b/assets/scripts/login.js index f054a4d..3b82359 100644 --- a/assets/scripts/login.js +++ b/assets/scripts/login.js @@ -2,7 +2,7 @@ var Login = function() { toastr.options = { 'closeButton': true, 'debug': false, - 'positionClass': 'toast-top-right', + 'positionClass': 'toast-bottom-right', 'showDuration': '5000', 'hideDuration': '1000', 'timeOut': '5000', diff --git a/index.html b/index.html index eee66e5..7d6e26b 100755 --- a/index.html +++ b/index.html @@ -760,7 +760,7 @@