From a2073f6ca643bea545d5f0998db576d8ce2bcb1d Mon Sep 17 00:00:00 2001 From: pbca26 Date: Thu, 2 Mar 2017 09:00:39 +0300 Subject: [PATCH] switched back old kmd_wallet_dashboard.js code --- assets/scripts/iguana_api.js | 4 +- assets/scripts/kmd_wallet_dashboard.js | 1401 +++++++++++++++++++++++- 2 files changed, 1375 insertions(+), 30 deletions(-) diff --git a/assets/scripts/iguana_api.js b/assets/scripts/iguana_api.js index b6c06f8..dadd260 100644 --- a/assets/scripts/iguana_api.js +++ b/assets/scripts/iguana_api.js @@ -756,7 +756,7 @@ function Iguana_addcoin(addcoin_data) { var tmpinternval = 6000, AddCoinData = {"conf":"WIRELESS.conf","path":confpath[0].path,"unitval":"20","zcash":1,"RELAY":-1,"VALIDATE":0,"prefetchlag":-1,"poll":100,"active":1,"agent":"iguana","method":"addcoin","startpend":4,"endpend":4,"services":129,"maxpeers":8,"newcoin":"WIRELESS","name":"WIRELESS","hasheaders":1,"useaddmultisig":0,"netmagic":"62071ed3","p2p":11666,"rpc":11667,"pubval":60,"p2shval":85,"wifval":188,"txfee_satoshis":"10000","isPoS":0,"minoutput":10000,"minconfirms":2,"genesishash":"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71","protover":170002,"genesisblock":"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2","debug":0,"seedipaddr":"78.47.196.146"} } else { - var AddCoinData = + var AddCoinData = {'userpass':tmpIguanaRPCAuth,"unitval":"20","zcash":1,"RELAY":addcoin_data.mode,"VALIDATE":addcoin_data.mode,"prefetchlag":-1,"poll":100,"active":1,"agent":"iguana","method":"addcoin","startpend":4,"endpend":4,"services":129,"maxpeers":8,"newcoin":"WIRELESS","name":"WIRELESS","hasheaders":1,"useaddmultisig":0,"netmagic":"62071ed3","p2p":11666,"rpc":11667,"pubval":60,"p2shval":85,"wifval":188,"txfee_satoshis":"10000","isPoS":0,"minoutput":10000,"minconfirms":2,"genesishash":"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71","protover":170002,"genesisblock":"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2","debug":0,"seedipaddr":"78.47.196.146"} } } @@ -1602,7 +1602,7 @@ function EDEXimportprivkey(params_data) { } function Iguana_SetRPCAuth() { - var tmpPass = '1234'; //md5(PassPhraseGenerator.generatePassPhrase(128)); + var tmpPass = md5(PassPhraseGenerator.generatePassPhrase(128)); sessionStorage.setItem('IguanaRPCAuth', tmpPass); } diff --git a/assets/scripts/kmd_wallet_dashboard.js b/assets/scripts/kmd_wallet_dashboard.js index ce5f03a..c1e7157 100644 --- a/assets/scripts/kmd_wallet_dashboard.js +++ b/assets/scripts/kmd_wallet_dashboard.js @@ -1,3 +1,265 @@ +var KMDWalletDashboard = function() { + var handle_KMD_Dashboard = function() { + var action_btn_code = getHeaderActionMenuButtonCoinCode(); + $('#btn_' + action_btn_code + '_wallet_dashboard').click(function() { + console.log('kmd wallet dashbaord button clicked...'); + console.log($(this).data()); + if ( sessionStorage.getItem('edexTmpMode') === 'Native') { + sessionStorage.setItem('edexTmpRefresh', 'start'); + } + if ( sessionStorage.getItem('edexTmpMode') === 'Basilisk' || sessionStorage.getItem('edexTmpMode') === 'Full' ) { + sessionStorage.setItem('edexTmpRefresh', 'stop'); + } + $('#kmd_wallet_dashoard_section').show(); + $('#kmd_wallet_dashboardinfo').show(); + $('#kmd_wallet_send').hide(); + $('#kmd_wallet_recieve_section').hide(); + $('#kmd_wallet_settings').hide(); + getTotalKMDBalance(); + KMDfillTxHistoryT(); + clearSendManyFieldData(); + }); + + $('.btn-kmdtxid').click(function() { + console.log('kmd-txid-details-btn button clicked!..'); + console.log($(this).data('txid-type')); + console.log($(this).data('txid')); + + var kmd_addr_txid_info = KMDGetTransactionIDInfo($(this).data('txid')); + console.log(kmd_addr_txid_info); + $('#kmd_txid_info_amount').text(kmd_addr_txid_info[0].amount); + $('#kmd_txid_info_fee').text(kmd_addr_txid_info[0].fee); + $('#kmd_txid_info_confirmations').text(kmd_addr_txid_info[0].confirmations); + $('#kmd_txid_info_blockhash').text(kmd_addr_txid_info[0].blockhash); + $('#kmd_txid_info_blockindex').text(kmd_addr_txid_info[0].blockindex); + $('#kmd_txid_info_blocktime').text(kmd_addr_txid_info[0].blocktime); + $('#kmd_txid_info_txid').text(kmd_addr_txid_info[0].txid); + $('#kmd_txid_info_walletconflicts').text(kmd_addr_txid_info[0].walletconflicts); + $('#kmd_txid_info_time').text(kmd_addr_txid_info[0].time); + $('#kmd_txid_info_timereceived').text(kmd_addr_txid_info[0].timereceived); + $('#kmd_txid_info_vjoinsplit').text(kmd_addr_txid_info[0].vjoinsplit); + $('#kmd_txid_info_details').text(kmd_addr_txid_info[0].details); + $('#kmd_txid_info_hex').val(kmd_addr_txid_info[0].hex); + clearSendManyFieldData(); + }); + + } + + var handle_KMD_Send = function() { + var action_btn_code = getHeaderActionMenuButtonCoinCode(); + + $('#btn_' + action_btn_code + '_wallet_send').click(function() { + var tmpoptions = ''; + + KMDListAllOPIDs(); + sessionStorage.setItem('edexTmpRefresh', 'stop'); + + $('#kmd_wallet_dashboardinfo').hide(); + $('#kmd_wallet_send').show(); + $('#kmd_wallet_recieve_section').hide(); + $('#kmd_wallet_settings').hide(); + + var kmd_addr_list_with_balance = KMDlistunspentT(); + + tmpoptions += ''; + $.each(kmd_addr_list_with_balance, function(index) { + tmpoptions += ''; + $('#kmd_wallet_send_from').html(tmpoptions); + }); + + var kmd_z_addr_list_with_balance = KMDListaddrZ(); + $.each(kmd_z_addr_list_with_balance, function(index) { + if (kmd_z_addr_list_with_balance[index].total !== 0) { + tmpoptions += ''; + $('#kmd_wallet_send_from').html(tmpoptions); + } + }); + + $('.showkmdwalletaddrs').selectpicker({ style: 'btn-info' }); + $('.showkmdwalletaddrs').selectpicker('refresh'); + clearSendManyFieldData(); + }); + + $('.showkmdwalletaddrs').on('change', function(){ + var selected = $(this).find("option:selected").val(); + }); + + $('#kmd_wallet_amount').keyup(function() { + var sum_val1 = parseFloat($('#kmd_wallet_amount').val()), + sum_val2 = parseFloat($('#kmd_wallet_fee').val()), + total_minus_currency_fee = sum_val1 - sum_val2, + mdl_send_btn = $('#kmd_wallet_send_coins_btn'); + + $('#kmd_wallet_total_value').text(total_minus_currency_fee.toFixed(8)); + + if ($('#kmd_wallet_send_from').val() != '- Select Transparent or Private KMD Address -' && + $('#kmd_wallet_amount').val() != '' && + $('#kmd_wallet_sendto') != '' && + $('#kmd_wallet_fee') != '' ) { + mdl_send_btn.removeClass('disabled'); + //mdl_send_btn.attr('data-dismiss','modal'); + //mdl_send_btn.attr('data-target','#SendCoinModelStep2'); + } else { + mdl_send_btn.addClass('disabled'); + mdl_send_btn.removeAttr('data-dismiss'); + mdl_send_btn.removeAttr('data-target'); + } + }); + + $('#kmd_wallet_fee').keyup(function() { + var sum_val1 = parseFloat($('#kmd_wallet_amount').val()), + sum_val2 = parseFloat($('#kmd_wallet_fee').val()), + total_minus_currency_fee = sum_val1 - sum_val2, + mdl_send_btn = $('#kmd_wallet_send_coins_btn'); + + $('#kmd_wallet_total_value').text(total_minus_currency_fee.toFixed(8)); + + if ($('#kmd_wallet_send_from').val() != '- Select Transparent or Private KMD Address -' && + $('#kmd_wallet_amount').val() != '' && + $('#kmd_wallet_sendto') != '' && + $('#kmd_wallet_fee') != '' ) { + mdl_send_btn.removeClass('disabled'); + //mdl_send_btn.attr('data-dismiss','modal'); + //mdl_send_btn.attr('data-target','#SendCoinModelStep2'); + } else { + mdl_send_btn.addClass('disabled'); + mdl_send_btn.removeAttr('data-dismiss'); + mdl_send_btn.removeAttr('data-target'); + } + }); + + /*$('#kmd_wallet_send_coins_btn').click(function() { + console.log('send button clicked in form...') + });*/ + + $('.extcoin-send-form').validate({ + // errorElement: 'span', //default input error message container + // errorClass: 'help-block', // default input error message class + // focusInvalid: false, // do not focus the last invalid input + rules: { + kmd_wallet_send_from: { + required: true + }, + kmd_wallet_sendto: { + required: true + }, + kmd_wallet_amount: { + required: true + }, + kmd_wallet_fee: { + required: true + }, + kmd_wallet_total_value: { + required: true + } + }, + + messages: { + kmd_wallet_send_from: { + required: 'From Address is required.' + }, + kmd_wallet_sendto: { + required: 'To Address is required.' + }, + kmd_wallet_amount: { + required: 'Please enter KMD amount to send.' + }, + kmd_wallet_fee: { + required: 'Make sure you have fee entered. Default value is 0.0001 KMD.' + }, + kmd_wallet_total_value: { + required: 'Make sure you have both amount and fee entered to calculate final total.' + } + }, + + submitHandler: function(form) { + console.log('Sent control here after clicked in form...'); + KMDZSendManyTransaction(); + clearSendManyFieldData(); + } + }); + + $('.extcoin-send-form #kmd_wallet_send_coins_btn').keypress(function(e) { + if (e.which == 13) { + if ($('.extcoin-send-form').validate().form()) { + $('.extcoin-send-form').submit(); // form validation success, call ajax form submit + } + + return false; + } + }); + + $('#kmd_opids_status_btn').click(function(){ + KMDListAllOPIDs(); + }); + } + + var KMDWalletSettings = function() { + var action_btn_code = getHeaderActionMenuButtonCoinCode(); + + $('#btn_' + action_btn_code + '_wallet_settings').click(function() { + console.log('wallet settings button clicked...'); + sessionStorage.setItem('edexTmpRefresh', 'stop'); + $('#kmd_wallet_dashboardinfo').hide(); + $('#kmd_wallet_dashoard_section').hide(); + $('#kmd_wallet_send').hide(); + $('#kmd_wallet_recieve_section').hide(); + $('#kmd_wallet_settings').show(); + getKMDWalletInfo(); + getKMDInfo(); + clearSendManyFieldData(); + }); + }; + + var KMDWalletRecieve = function() { + var action_btn_code = getHeaderActionMenuButtonCoinCode(); + + $('#btn_' + action_btn_code + '_wallet_recieve').click(function() { + sessionStorage.setItem('edexTmpRefresh', 'stop'); + $('#kmd_wallet_dashboardinfo').hide(); + $('#kmd_wallet_dashoard_section').hide(); + $('#kmd_wallet_send').hide(); + $('#kmd_wallet_recieve_section').show(); + $('#kmd_wallet_settings').hide(); + KMDListAllAddr(); + clearSendManyFieldData(); + }); + + $('#kmd_get_new_taddr').click(function() { + console.log('get new T address button clicked...'); + KMDGetNewAddresses('public'); + KMDListAllAddr(); + toastr.info('Receiving Address list updated', 'Wallet Notification'); + }); + + $('#kmd_get_new_zaddr').click(function() { + console.log('get new Z address button clicked...'); + KMDGetNewAddresses('private'); + KMDListAllAddr(); + toastr.info('Receiving Address list updated', 'Wallet Notification'); + }); + }; + + var handleWalletDashboardAlet = function() { + $('#extcoin-wallet-connection-alert-btn').click(function() { + RunKMDInitFunctions(); + }); + } + + return { + // main function to initiate the module + init: function() { + handle_KMD_Dashboard(); + //KMDfillTxHistoryT(); + handle_KMD_Send(); + KMDWalletRecieve(); + KMDWalletSettings(); + //RunKMDInitFunctions(); + handleWalletDashboardAlet(); + } + }; +}(); + jQuery(document).ready(function() { // KMDWalletDashboard.init(); // TODO: refactor @@ -32,6 +294,162 @@ jQuery(document).ready(function() { }, 30000); }); +function RunKMDInitFunctions() { + NProgress.done(true); + NProgress.configure({ + template: '
' + + '
' + + '
' + + '
' + }); + NProgress.start(); + + var check1 = CheckIfConnected(); + console.log(check1[0]); + if ( check1[0] == 'not active' ) { + console.log('Could not connect to external wallet. Is external wallet running?'); + toastr.error('Connection Error. Is external wallet running?', 'Wallet Notification'); + $('#extcoin-wallet').hide(); + $('#extcoin-wallet-connection-alert').show(); + } + if ( check1[0] == 'null return' ) { + console.log('Could not connect to external wallet. Is iguana connected to external wallet?'); + toastr.error('Connection Error. Is iguana connected to external wallet?', 'Wallet Notification'); + $('#extcoin-wallet').hide(); + $('#extcoin-wallet-connection-alert').show(); + } + if ( check1[0] == 'activating' ) { + $('#extcoin-wallet-activating-alert').show(); + $('#extcoin-wallet').show(); + $('#extcoin-wallet-connection-alert').hide(); + + function _getKMDInfo() { + var passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'getinfo', + 'hex': '' + }; + + console.log(ajax_data); + $.ajax({ + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + + if (AjaxOutputData && !AjaxOutputData.blocks) { + startBestBlockInterval(); + } else { + clearInterval(currentBestBlockInterval); + } + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + } + + function getRemoteCurrentHeight() { + $.ajax({ + type: 'GET', + url: 'http://localhost:7778/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=KMD', + success: function(data, textStatus, jqXHR) { + data = JSON.parse(data); + + if (data && data.blocks) { + totalBlocksInExplorer = data.blocks; + } + }, + error: function(xhr, textStatus, error) { + console.log('failed getinfo from dex api'); + console.log(xhr.statusText); + console.log(textStatus); + console.log(error); + } + }); + } + + var currentBestBlockInterval; + function startBestBlockInterval() { + currentBestBlockInterval = setInterval(function() { + $.ajax({ + type: 'POST', + data: { + 'herdname': 'komodo', + 'lastLines': 1 + }, + url: 'http://127.0.0.1:17777/shepherd/debuglog', + success: function(data, textStatus, jqXHR) { + if (data.indexOf('UpdateTip') > -1) { + var temp = data.split(' '); + + for (var i = 0; i < temp.length; i++) { + if (temp[i].indexOf('height=') > -1) { + var currentBestChain = temp[i].replace('height=', ''); + $('#activating-komodod-tridot').hide(); + $('#activating-komodod-progress').html(': ' + Math.floor(currentBestChain * 100 / totalBlocksInExplorer) + '% (blocks ' + currentBestChain + ' / ' + totalBlocksInExplorer + ')'); + + if (currentBestChain === totalBlocksInExplorer) { + //clearInterval(totalBlocksInExplorerInterval); + clearInterval(currentBestBlockInterval); + } + } + } + } + }, + error: function(xhr, textStatus, error) { + console.log('failed getting debug.log'); + console.log(xhr.statusText); + console.log(textStatus); + console.log(error); + } + }); + }, 2000); + } + + getRemoteCurrentHeight(); + + var totalBlocksInExplorer = 0, + totalBlocksInExplorerInterval = setInterval(function() { + getRemoteCurrentHeight(); + _getKMDInfo(); + }, 60000); + + $('#kmd_wallet_dashoard_section').show(); + $('#kmd_wallet_dashboardinfo').show(); + $('#kmd_wallet_send').hide(); + $('#kmd_wallet_recieve_section').hide(); + $('#kmd_wallet_settings').hide(); + } + if ( check1[0] == 'connected') { + getTotalKMDBalance(); + KMDfillTxHistoryT(); + $('#extcoin-wallet').show(); + $('#extcoin-wallet-connection-alert').hide(); + + $('#kmd_wallet_dashoard_section').show(); + $('#kmd_wallet_dashboardinfo').show(); + $('#kmd_wallet_send').hide(); + $('#kmd_wallet_recieve_section').hide(); + $('#kmd_wallet_settings').hide(); + } + + // KMDWalletDashboard.init() + $('#kmd_wallet_recieve_section').hide(); + NProgress.done(); +} + function getHeaderActionMenuButtonCoinCode() { var extcoin = $('[data-extcoin]').attr('data-extcoin'), action_menu_button_code = ''; @@ -52,40 +470,155 @@ function getPassthruAgent() { return passthru_agent; } -function CheckIfConnected() { - var result = [], - extcoin = $('[data-extcoin]').attr('data-extcoin'), - passthru_agent = getPassthruAgent(), +function getTotalKMDBalance() { + var extcoin = $('[data-extcoin]').attr('data-extcoin'), + passthru_agent = ''; + + console.log($('[data-extcoin]').attr('data-extcoin')); + + if ( extcoin == 'KMD') { passthru_agent = 'komodo'; }; + if ( extcoin == 'ZEC') { passthru_agent = 'zcash'; }; + + var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'z_gettotalbalance', + 'hex': '3000' + }; + + console.log(ajax_data); + $.ajax({ + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + //dataType: 'text', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + + if (AjaxOutputData.interest != undefined) { + console.log('show interest..'); + $('#kmd_total_interest_balance').text(parseFloat(AjaxOutputData.interest).toFixed(8) + ' ' + extcoin); + $('#kmd_widget_get_total_balance_i').show(); + $('#kmd_widget_get_total_balance_t').addClass(' col-lg-3'); + $('#kmd_widget_get_total_balance_t').removeClass('col-lg-4'); + $('#kmd_widget_get_total_balance_z').addClass(' col-lg-3'); + $('#kmd_widget_get_total_balance_z').removeClass(' col-lg-4'); + $('#kmd_widget_get_total_balance_tzi').addClass(' col-lg-3'); + $('#kmd_widget_get_total_balance_tzi').removeClass(' col-lg-4'); + } else { + console.log('do not show interest...'); + $('#kmd_widget_get_total_balance_i').hide(); + $('#kmd_widget_get_total_balance_t').addClass(' col-lg-4'); + $('#kmd_widget_get_total_balance_t').removeClass(' col-lg-3'); + $('#kmd_widget_get_total_balance_z').addClass(' col-lg-4'); + $('#kmd_widget_get_total_balance_z').removeClass(' col-lg-3'); + $('#kmd_widget_get_total_balance_tzi').addClass(' col-lg-4'); + $('#kmd_widget_get_total_balance_tzi').removeClass(' col-lg-3'); + } + $('#kmd_transparent_balance').text((AjaxOutputData.transparent ? parseFloat(AjaxOutputData.transparent).toFixed(8) : 0) + ' ' + extcoin); + $('#kmd_private_balance').text((AjaxOutputData.private ? parseFloat(AjaxOutputData.private).toFixed(8) : 0) + ' ' + extcoin); + $('#kmd_total_tz_balance').text((AjaxOutputData.total ? parseFloat(AjaxOutputData.total).toFixed(8) : 0) + ' ' + extcoin); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); +} + +function getKMDBalanceT() { + var passthru_agent = getPassthruAgent(), tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), ajax_data = { 'userpass': tmpIguanaRPCAuth, 'agent': passthru_agent, 'method': 'passthru', - 'function': 'getinfo', + 'function': 'getbalance', 'hex': '' }; - + console.log(ajax_data); $.ajax({ - async: false, type: 'POST', data: JSON.stringify(ajax_data), url: 'http://127.0.0.1:7778', success: function(data, textStatus, jqXHR) { var AjaxOutputData = JSON.parse(data); - console.log('== Data OutPut =='); - console.log(AjaxOutputData); - console.log(AjaxOutputData.error); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); +} - if ( AjaxOutputData.errors != undefined ) { - result.push('connected'); - } else if ( AjaxOutputData['error'].message = 'Activating best chain...' ) { - result.push('activating'); - } else if ( AjaxOutputData.errors == undefined) { - result.push('not active'); - } else { - result.push(AjaxOutputData.errors); + +function getKMDBalanceZ() { + var passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'z_getbalance', + 'hex': '' + }; + + console.log(ajax_data); + $.ajax({ + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); } + console.log(textStatus); + console.log(error); + } + }); +} + +function getKMDWalletInfo() { + var passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'getwalletinfo', + 'hex': '' + }; + + console.log(ajax_data); + $.ajax({ + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + $('#kmd_walletversion').text(AjaxOutputData.walletversion); + $('#kmd_balance').text(AjaxOutputData.balance); + $('#kmd_unconfirmed_balance').text(AjaxOutputData.unconfirmed_balance); + $('#kmd_immature_balance').text(AjaxOutputData.immature_balance); + $('#KMDTotalTransactionsCount').text(AjaxOutputData.txcount); }, error: function(xhr, textStatus, error) { console.log('failed getting Coin History.'); @@ -97,11 +630,61 @@ function CheckIfConnected() { console.log(error); } }); - - return result; } -function CheckIfWalletEncrypted() { +function getKMDInfo() { + var passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'getinfo', + 'hex': '' + }; + + console.log(ajax_data); + $.ajax({ + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + $('#kmd_version').text(AjaxOutputData.version); + $('#kmd_protocolversion').text(AjaxOutputData.protocolversion); + $('#kmd_notarized').text(AjaxOutputData.notarized); + $('#kmd_notarizedhash').text(AjaxOutputData.notarizedhash); + $('#kmd_notarizedbtc').text(AjaxOutputData.notarizedbtc); + $('#kmd_blocks').text(AjaxOutputData.blocks); + $('#kmd_connections').text(AjaxOutputData.connections); + $('#kmd_difficulty').text(AjaxOutputData.difficulty); + $('#kmd_testnet').text(AjaxOutputData.testnet); + $('#kmd_paytxfee').text(AjaxOutputData.paytxfee); + $('#kmd_relayfee').text(AjaxOutputData.relayfee); + $('#kmd_errors').text(AjaxOutputData.errors); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); +} + +function KMDlistunspentT() { + NProgress.done(true); + NProgress.configure({ + template: '
' + + '
' + + '
' + + '
' + }); + NProgress.start(); + var result = [], passthru_agent = getPassthruAgent(), tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), @@ -109,21 +692,783 @@ function CheckIfWalletEncrypted() { 'userpass': tmpIguanaRPCAuth, 'agent': passthru_agent, 'method': 'passthru', - 'function': 'walletlock', + 'function': 'listunspent', 'hex': '' }; - - console.log(ajax_data); + $.ajax({ async: false, type: 'POST', data: JSON.stringify(ajax_data), url: 'http://127.0.0.1:7778', + //dataType: 'text', success: function(data, textStatus, jqXHR) { - var AjaxOutputData = JSON.parse(data); - console.log('== Data OutPut =='); - console.log(AjaxOutputData.error); - + var AjaxOutputData = JSON.parse(data), // Ajax output gets the whole list of unspent coin with addresses + unique_addresses = _.keys(_.countBy(AjaxOutputData, function(data) { return data.address; })); // This code using underscore.js takes only the address into an array which are unique in that list + + // This function calls each unique address and calculates the total amount of coins in it. + $.each(unique_addresses, function(index) { + var unique_addr_tmp_array = _.where(AjaxOutputData, { address: unique_addresses[index] }), + tmpcalcnum = 0; + + $.each(unique_addr_tmp_array, function(index, value) { + tmpcalcnum = tmpcalcnum + value.amount; + }); + + var tmp_addr_total_balance_output = { + 'addr': unique_addr_tmp_array[0].address, + 'total': tmpcalcnum + }; + result.push(tmp_addr_total_balance_output); + }); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + + NProgress.done(); + return result; +} + +function KMDListaddrZ() { + var result = []; + + var passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'z_listaddresses', + 'hex': '' + }; + + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); // Ajax output gets the whole list of unspent coin with addresses + // This code gets list of all z_addresses into an array + // This function calls each address and then gets the total amount of coins in it. + $.each(AjaxOutputData, function(index, value) { + var ajax_data_to_hex = '["' + value + '",0]', + tmpZaddrs_output = Iguana_HashHex(ajax_data_to_hex), + passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data_zaddrbalance = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'z_getbalance', + 'hex': tmpZaddrs_output + }; + + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data_zaddrbalance), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + + if (AjaxOutputData.hasOwnProperty('error')) { + AjaxOutputData = 0; + } + var tmp_Zaddr_total_balance_output = { + 'addr': value, + 'total': AjaxOutputData + }; + + result.push(tmp_Zaddr_total_balance_output); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + }); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + + return result; +} + + +function KMDGetPublicTransactions() { + NProgress.done(true); + NProgress.configure({ + template: '
' + + '
' + + '
' + + '
' + }); + NProgress.start(); + + var result = [], + passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'listtransactions', + 'hex': '' + }; + + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); // Ajax output gets the whole list of unspent coin with addresses + console.log(AjaxOutputData); + + $.each(AjaxOutputData, function(index, value) { + var tmp_category = '', + tmp_addr = AjaxOutputData[index].address; + + if (!('address' in AjaxOutputData[index])) { + tmp_addr = ' Z Address not listed by wallet!'; + } + var tmp_secondsToString = secondsToString(AjaxOutputData[index].time); + + if ( AjaxOutputData[index].category == 'send' ) { + tmp_category = ' OUT'; + } + if ( AjaxOutputData[index].category == 'receive' ) { + tmp_category = ' IN'; + } + if ( AjaxOutputData[index].category == 'generate' ) { + tmp_category = ' Mined'; + } + if ( AjaxOutputData[index].category == 'immature' ) { + tmp_category = ' Immature'; + } + + tmplisttransactions = [ + '' + + ' public' + + '', + tmp_category, + AjaxOutputData[index].confirmations, + AjaxOutputData[index].amount, + tmp_secondsToString, + tmp_addr, + '' + ]; + result.push(tmplisttransactions); + }); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + + NProgress.done(); + return result; +} + +function KMDGetProtectedTransactions() { + NProgress.done(true); + NProgress.configure({ + template: '
' + + '
' + + '
' + + '
' + }); + NProgress.start(); + + var result = [], + get_zaddr_list = KMDListaddrZ(); + + $.each(get_zaddr_list, function(index, value) { + var ajax_data_to_hex = '["' + value.addr + '",0]', + tmpzaddr_hex_input = Iguana_HashHex(ajax_data_to_hex), + passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@ '+ sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + "agent": passthru_agent, + "method": "passthru", + "function": "z_listreceivedbyaddress", + "hex": tmpzaddr_hex_input + }; + + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); // Ajax output gets the whole list of unspent coin with addresses + + $.each(AjaxOutputData, function(index, txidvalue) { + var tmp_category = ' IN'; + var tmp_addr = value.addr.slice(0, 30) + '...'; + if (!('amount' in txidvalue)) { + var tmp_amount = 0; + } else { + var tmp_amount = txidvalue.amount; + } + + var tmp_addr_txid_info = KMDGetTransactionIDInfo(AjaxOutputData[index].txid), + tmp_confirmations = tmp_addr_txid_info[0].confirmations, + tmp_secondsToString = secondsToString(tmp_addr_txid_info[0].time), + tmplistZtransactions = [ + '' + + ' private' + + '', + tmp_category, + tmp_confirmations, + tmp_amount, + tmp_secondsToString, + tmp_addr, + '' + ]; + result.push(tmplistZtransactions); + }); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + }); + + NProgress.done(); + return result; +} + +function KMDfillTxHistoryT() { + NProgress.done(true); + NProgress.configure({ + template: '
' + + '
' + + '
' + + '
' + }); + NProgress.start(); + + var txhistorydataT = KMDGetPublicTransactions(); + //var txhistorydataZ = KMDGetProtectedTransactions(); + //var txhistorydata = $.merge( txhistorydataT, txhistorydataZ ); + var txhistorydata = txhistorydataT, + kmd_txhistory_table = ''; + + kmd_txhistory_table = $('#kmd-tx-history-tbl').DataTable({ + data: txhistorydata, + 'order': [ + [ + 4, + 'desc' + ] + ], + select: true, + retrieve: true + }); + + kmd_txhistory_table.destroy(); + kmd_txhistory_table = $('#kmd-tx-history-tbl').DataTable({ + data: txhistorydata, + 'order': [ + [ + 4, + 'desc' + ] + ], + select: true, + retrieve: true + }); + + NProgress.done(); +} + +function KMDListAddresses(pubpriv) { + NProgress.done(true); + NProgress.configure({ + template: '
' + + '
' + + '
' + + '
' + }); + NProgress.start(); + + var result = [], + ajax_data_to_hex = '""', + ajax_function_input = '', + tmplistaddr_hex_input = ''; + + if ( pubpriv === 'public' ) { + ajax_function_input = 'getaddressesbyaccount'; + tmplistaddr_hex_input = Iguana_HashHex(ajax_data_to_hex); + } + if ( pubpriv === 'private' ) { + ajax_function_input = 'z_listaddresses'; + tmplistaddr_hex_input = ''; + } + + var passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': ajax_function_input, + 'hex': tmplistaddr_hex_input + }; + + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); // Ajax output gets the whole list of unspent coin with addresses + result = AjaxOutputData; + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + + NProgress.done(); + return result; +} + + +function KMDGetNewAddresses(pubpriv) { + NProgress.done(true); + NProgress.configure({ + template: '
' + + '
' + + '
' + + '
' + }); + NProgress.start(); + + var result = [], + ajax_function_input = ''; + + if ( pubpriv === 'public' ) { + ajax_function_input = 'getnewaddress'; + } + if ( pubpriv === 'private' ) { + ajax_function_input = 'z_getnewaddress'; + } + + var passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': ajax_function_input, + 'hex': '' + }; + + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + result = data; + toastr.success('New address generated successfully', 'Wallet Notification'); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + + NProgress.done(); + return result; +} + +function KMDListAllAddr() { + NProgress.done(true); + NProgress.configure({ + template: '
' + }); + NProgress.start(); + + var only_reciving_addr_data = [], + listTaddr = KMDListAddresses('public'), + listZaddr = KMDListAddresses('private'), + listAlladdr = $.merge( listTaddr, listZaddr ); + + $.each(listAlladdr, function(index, value) { + tmp_addr_label = '' + + ' public' + + ''; + if ( listAlladdr[index].slice(0, 2) == 'zc' || listAlladdr[index].slice(0, 2) == 'zt' ) { + tmp_addr_label = '' + + ' private' + + ''; + } + //var tmp_addr_action_button = ''; + only_reciving_addr_data.push([ + tmp_addr_label, + listAlladdr[index] + ]); + }); + + var kmd_recieve_table = ''; + + kmd_recieve_table = $('#kmd-recieve-addr-tbl').DataTable({ + data: only_reciving_addr_data, + select: false, + retrieve: true + }); + + kmd_recieve_table.destroy(); + + kmd_recieve_table = $('#kmd-recieve-addr-tbl').DataTable({ + data: only_reciving_addr_data, + select: false, + retrieve: true + }); + + NProgress.done(); + return only_reciving_addr_data; +} + +function KMDGetTransactionIDInfo(txid) { + var result = [], + ajax_data_to_hex = '["' + txid + '"]', + tmptxid_output = Iguana_HashHex(ajax_data_to_hex), + passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data_txid_input = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'gettransaction', + 'hex': tmptxid_output + }; + + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data_txid_input), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + result.push(AjaxOutputData); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + + return result; +} + +function KMDGetOPIDInfo(opid) { + var result = [], + tmpopid_output = ''; + + if ( opid === undefined ) { + tmpopid_output = ''; + } else { + var ajax_data_to_hex = '["' + opid + '"]', + tmpopid_output = Iguana_HashHex(ajax_data_to_hex); + } + + var passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data_txid_input = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'z_getoperationstatus', + 'hex': tmpopid_output + }; + + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data_txid_input), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + result.push(AjaxOutputData); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + + return result; +} + +function KMDListAllOPIDs() { + NProgress.done(true); + NProgress.configure({ + template: '
' + + '
' + + '
' + + '
' + }); + NProgress.start(); + + var opids_statuses_data = [], + listOPIDs = KMDGetOPIDInfo(), + tmp_results = 'Waiting...', + tmp_status_label = '', + tmp_creation_time = '', + tmp_id = ''; + + console.log(listOPIDs); + $.each(listOPIDs[0], function(index, value) { + tmp_id = listOPIDs[0][index].id; + tmp_creation_time = secondsToString(listOPIDs[0][index].creation_time); + + if (listOPIDs[0][index].status === 'queued') { + tmp_status_label = '' + + ' Queued' + + ''; + tmp_results = 'Please press refresh button in a minute or so to see updated status...'; + } + if (listOPIDs[0][index].status === 'executing') { + tmp_status_label = '' + + ' Executing' + + ''; + tmp_results = 'Please press refresh button in a minute or so to see updated status...'; + } + if (listOPIDs[0][index].status === 'failed') { + tmp_status_label = '' + + ' Failed' + + ''; + tmp_results = 'Error Code: ' + listOPIDs[0][index].error.code + '
Message: ' + listOPIDs[0][index].error.message; + } + if (listOPIDs[0][index].status === 'success') { + tmp_status_label = '' + + ' Success' + + ''; + tmp_results = 'txid: ' + listOPIDs[0][index].result.txid + '
Execution Seconds: ' + listOPIDs[0][index].execution_secs; + } + + opids_statuses_data.push([ + tmp_status_label, + tmp_id, + tmp_creation_time, + tmp_results + ]); + }); + + var kmd_opids_statuses_table = ''; + + kmd_opids_statuses_table = $('#kmd-opid-status-tbl').DataTable({ + data: opids_statuses_data, + 'order': [ + [ + 2, + 'desc' + ] + ], + select: false, + retrieve: true + }); + + kmd_opids_statuses_table.destroy(); + + kmd_opids_statuses_table = $('#kmd-opid-status-tbl').DataTable({ + data: opids_statuses_data, + 'order': [ + [ + 2, + 'desc' + ] + ], + select: false, + retrieve: true + }); + + NProgress.done(); + return opids_statuses_data; +} + +function KMDZSendManyTransaction() { + var result = [], + zsendmoney_output = '', + tmp_zsendmany_from_addr = $('#kmd_wallet_send_from').val(), + tmp_zsendmany_to_addr = $('#kmd_wallet_sendto').val(), + tmp_zsendmany_total_amount = $('#kmd_wallet_total_value').text(), + ajax_data_to_hex = '["' + tmp_zsendmany_from_addr + '",[{"address":"' + tmp_zsendmany_to_addr + '","amount":' + tmp_zsendmany_total_amount + '}]]', + zsendmoney_output = Iguana_HashHex(ajax_data_to_hex), + passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data_txid_input = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'z_sendmany', + 'hex': zsendmoney_output + }; + + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data_txid_input), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + console.log('== Data OutPut of z_sendmany =='); + console.log(data); + result.push(data); + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + + KMDListAllOPIDs(); + return result; +} + +function clearSendManyFieldData() { + $('.showkmdwalletaddrs').selectpicker('refresh'); + $('#kmd_wallet_sendto').val(''); + $('#kmd_wallet_total_value').text(''); + $('#kmd_wallet_amount').val(''); +} + +function CheckIfConnected() { + var result = [], + extcoin = $('[data-extcoin]').attr('data-extcoin'), + passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'getinfo', + 'hex': '' + }; + + console.log(ajax_data); + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + console.log('== Data OutPut =='); + console.log(AjaxOutputData); + console.log(AjaxOutputData.error); + + if ( AjaxOutputData.errors != undefined ) { + result.push('connected'); + } else if ( AjaxOutputData['error'].message = 'Activating best chain...' ) { + result.push('activating'); + } else if ( AjaxOutputData.errors == undefined) { + result.push('not active'); + } else { + result.push(AjaxOutputData.errors); + } + }, + error: function(xhr, textStatus, error) { + console.log('failed getting Coin History.'); + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + + return result; +} + +function CheckIfWalletEncrypted() { + var result = [], + passthru_agent = getPassthruAgent(), + tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + ajax_data = { + 'userpass': tmpIguanaRPCAuth, + 'agent': passthru_agent, + 'method': 'passthru', + 'function': 'walletlock', + 'hex': '' + }; + + console.log(ajax_data); + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + console.log('== Data OutPut =='); + console.log(AjaxOutputData.error); + if ( AjaxOutputData.errors != undefined ) { result.push('encrypted'); } else {