Browse Source

kmd send section related UI and JS code added

z_listaddresses and z_getbalance js function also added to get list of
z addresses with their balance. Just waiting for passthru hex issue to
solve. Once working it will show z addresses in send section’s send
from address list as well.
master
Satinder Grewal 8 years ago
parent
commit
8d517d04dd
  1. 30
      assets/scripts/iguana_api.js
  2. 118
      assets/scripts/kmd_wallet_dashboard.js
  3. 43
      index.html

30
assets/scripts/iguana_api.js

@ -370,4 +370,34 @@ function Iguana_ServiceUnavailable() {
console.log('Network Error with history api');
toastr.error("Unable to connect with iguana service. 127.0.0.1:7778", "Service Notification")
toastr.info("Are you sure Iguana is running?", "Account Notification")
}
function Iguana_HashHex(data) {
var result = '';
//console.log(data);
var ajax_data = {"agent":"hash","method":"hex","message":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('== Hex Data OutPut ==');
//console.log(AjaxOutputData);
result = AjaxOutputData.hex;
},
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;
}

118
assets/scripts/kmd_wallet_dashboard.js

@ -5,6 +5,8 @@ var KMDWalletDashboard = function() {
$('#btn_kmd_wallet_dashboard').click(function() {
//console.log('kmd wallet dashbaord button clicked...');
$('#kmd_wallet_dashoard_section').show();
$('#kmd_wallet_dashboardinfo').show();
$('#kmd_wallet_send').hide();
getTotalKMDBalance();
getKMDWalletInfo();
getKMDInfo();
@ -12,10 +14,60 @@ var KMDWalletDashboard = function() {
});
}
var handle_KMD_Send = function() {
$('#btn_kmd_wallet_send').click(function() {
//console.log('kmd wallet send button clicked...');
var tmpoptions = '';
$('#kmd_wallet_dashboardinfo').hide();
$('#kmd_wallet_send').show();
var kmd_addr_list_with_balance = KMDlistunspentT();
//console.log(kmd_addr_list_with_balance);
tmpoptions += '<option> - Select Transparent or Private KMD Address - </option>';
$.each(kmd_addr_list_with_balance, function(index) {
tmpoptions += '<option value="' + kmd_addr_list_with_balance[index].addr + '" data-total="' + kmd_addr_list_with_balance[index].total.toFixed(8) + '">' + kmd_addr_list_with_balance[index].addr + ' &emsp;[ ' + kmd_addr_list_with_balance[index].total.toFixed(8) + ' KMD ]</option>';
$('#kmd_wallet_send_from').html(tmpoptions);
});
$('.showkmdwalletaddrs').selectpicker({ style: 'btn-info' });
});
$('.showkmdwalletaddrs').on('change', function(){
var selected = $(this).find("option:selected").val();
console.log(selected);
console.log($(this).find("option:selected").data('total'));
});
$('#kmd_wallet_amount').keyup(function() {
var sum_val1 = parseFloat($('#kmd_wallet_amount').val())
var sum_val2 = parseFloat($('#kmd_wallet_fee').val())
var total_minus_currency_fee = sum_val1 - sum_val2;
var mdl_send_btn = $('#kmd_wallet_send_btn');
console.log($('#kmd_wallet_amount').val());
$('#kmd_wallet_total_value').text(total_minus_currency_fee.toFixed(8));
if ($('#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');
mdl_send_btn.attr('onclick','ConfirmsendCurrency($(this).data())')
} else {
mdl_send_btn.addClass('disabled');
mdl_send_btn.removeAttr('data-dismiss');
mdl_send_btn.removeAttr('data-target');
mdl_send_btn.removeAttr('onclick');
}
});
}
return {
//main function to initiate the module
init: function() {
handle_KMD_Dashboard();
handle_KMD_Send();
RunInitFunctions();
}
};
@ -231,4 +283,70 @@ function KMDlistunspentT() {
});
//console.log(result);
return result;
}
function KMDListaddrZ() {
var result = [];
var ajax_data = {"agent":"komodo","method":"passthru","function":"z_listaddresses","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); //Ajax output gets the whole list of unspent coin with addresses
console.log('== Data OutPut of z_listaddresses ==');
console.log(AjaxOutputData);
//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) {
//console.log(value);
var ajax_data_to_hex = ['"'+value+'"',"1"];
var tmpZaddrs_output = Iguana_HashHex(ajax_data_to_hex);
//console.log(tmpZaddrs_output);
var ajax_data_zaddrbalance = {"agent":"komodo","method":"passthru","function":"z_getbalance","hex":tmpZaddrs_output}
console.log(ajax_data_zaddrbalance);
$.ajax({
type: 'POST',
data: JSON.stringify(ajax_data_zaddrbalance),
url: 'http://127.0.0.1:7778',
//dataType: 'text',
success: function(data, textStatus, jqXHR) {
var AjaxOutputData = JSON.parse(data);
console.log('== Data OutPut of z_getbalance ==');
console.log(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);
}
});
});
},
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);
}
});
//console.log(result);
return result;
}

43
index.html

@ -667,6 +667,7 @@
</div>
</div>
<div id="kmd_wallet_dashboardinfo">
<div class="col-xs-12">
<!-- Iguana Wallet Settings Box Tab -->
<div class="panel nav-tabs-horizontal">
@ -727,7 +728,49 @@
</div>
<!-- End Iguana Wallet Settings Box Tab -->
</div>
</div>
<div id="kmd_wallet_send" style="display: none;">
<div class="col-xlg-12 col-md-12 col-sm-12 col-xs-12">
<!-- Panel getinfo -->
<div class="panel" id="projects">
<div class="panel-heading">
<h3 class="panel-title">Send KMD</h3>
</div>
<div class="panel-body container-fluid">
<div class="row">
<div class="col-lg-6 form-group form-material">
<label class="control-label" for="kmd_wallet_send_from">Send From</label>
<select class="form-control form-material showkmdwalletaddrs show-tick" id="kmd_wallet_send_from" title="Select Transparent or Private KMD Address" data-size="5">
</select>
</div>
<div class="col-lg-6 form-group form-material">
<label class="control-label" for="kmd_wallet_sendto">Send To</label>
<input type="text" class="form-control" id="kmd_wallet_sendto" name="kmd_wallet_sendto" placeholder="Enter Transparent or Private KMD address" autocomplete="off" required/>
</div>
<div class="col-lg-6 form-group form-material">
<label class="control-label" for="kmd_wallet_amount" id="kmd_wallet_amount_label">KMD</label>
<input type="text" class="form-control" id="kmd_wallet_amount" name="kmd_wallet_amount" placeholder="0.000" autocomplete="off"/>
</div>
<div class="col-lg-6 form-group form-material">
<label class="control-label" for="kmd_wallet_fee">Fee</label>
<input type="text" class="form-control" id="kmd_wallet_fee" name="kmd_wallet_fee" placeholder="0.000" value="0.0001" autocomplete="off"/>
</div>
<div class="col-lg-12">
<span><b>Total (KMD - txfee):</b>
<span id="kmd_wallet_total_value">0.000</span> <span id="kmd_wallet_total_coinname">KMD</span>
</div>
</div>
</div>
</div>
<!-- End Panel getinfo -->
</div>
</div>
</div>
</div>
<!-- END KOMODO WALLET CONTENT BODY -->

Loading…
Cancel
Save