You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

288 lines
6.6 KiB

function IguanaAJAX(url, ajax_data) {
return $.ajax({
data: JSON.stringify(ajax_data),
url: url,
type: 'POST',
dataType: 'json'
})
.fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
Iguana_ServiceUnavailable();
}
console.log(textStatus);
console.log(error);
});
}
9 years ago
function Iguana_dumpwallet() {
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'bitcoinrpc',
'method': 'dumpwallet',
'filename': ''
};
return_result = function () {
9 years ago
var tmp = null;
$.ajax({
'async': false,
'type': 'POST',
'global': false,
8 years ago
'url': 'http://127.0.0.1:' + config.iguanaPort,
9 years ago
'data': JSON.stringify(ajax_data),
'success': function (data) {
tmp = data;
}
});
9 years ago
return tmp;
}();
//console.log(return_result);
//comment
/*var ajax_data = {"agent":"bitcoinrpc","method":"dumpwallet","filename": ""};
console.log(ajax_data);
$.ajax({
type: 'POST',
data: JSON.stringify(ajax_data),
8 years ago
url: 'http://127.0.0.1:' + config.iguanaPort,
//dataType: 'text',
success: function(data, textStatus, jqXHR) {
var AjaxOutputData = JSON.parse(data);
//console.log('== Data OutPut ==');
console.log(AjaxOutputData);
//return AjaxOutputData;
},
error: function(xhr, textStatus, error) {
console.log(xhr.statusText);
console.log(textStatus);
console.log(error);
}
});
//console.log(datareturn)
//return datareturn;*/
9 years ago
}
function Iguana_ServiceUnavailable() {
console.log('Network Error api');_lang[defaultLang]
toastr.error(_lang[defaultLang].TOASTR.IGUANA_CONN_ERR_ALT, _lang[defaultLang].TOASTR.SERVICE_NOTIFICATION);
toastr.info(_lang[defaultLang].TOASTR.IGUANA_ARE_YOU_SURE, _lang[defaultLang].TOASTR.ACCOUNT_NOTIFICATION);
8 years ago
ClearOnLogout(true, true);
}
8 years ago
function secondsToString(seconds) {
8 years ago
var a = new Date(seconds * 1000),
months = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
],
year = a.getFullYear(),
month = months[a.getMonth()],
date = a.getDate(),
hour = a.getHours(),
min = a.getMinutes(),
sec = a.getSeconds(),
time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec;
return time;
8 years ago
}
function Iguana_HashHex(data) {
8 years ago
var result = '',
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'hash',
'method': 'hex',
'message': data
};
8 years ago
$.ajax({
async: false,
8 years ago
type: 'POST',
data: JSON.stringify(ajax_data),
8 years ago
url: 'http://127.0.0.1:' + config.iguanaPort,
8 years ago
success: function(data, textStatus, jqXHR) {
var AjaxOutputData = JSON.parse(data);
result = AjaxOutputData.hex;
},
error: function(xhr, textStatus, error) {
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
Iguana_ServiceUnavailable();
}
console.log(textStatus);
console.log(error);
}
});
8 years ago
return result;
}
function Iguana_SetRPCAuth() {
var tmpPass = md5(PassPhraseGenerator.generatePassPhrase(128));
sessionStorage.setItem('IguanaRPCAuth', tmpPass);
}
8 years ago
function Iguana_CheckActiveCoins() {
8 years ago
return new Promise((resolve) => {
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'InstantDEX',
'method': 'allcoins'
},
8 years ago
AjaxOutputData = IguanaAJAX('http://127.0.0.1:' + config.iguanaPort, ajax_data).done(function(data) {
console.log(data);
var result = [];
AjaxOutputData = JSON.parse(AjaxOutputData.responseText);
$.each(AjaxOutputData, function( index, value ) {
if ( index === 'tag' ) {
//console.log('it is tag');
} else {
if (AjaxOutputData[index].length !== 0 ) {
result.push({ 'active': AjaxOutputData[index].length });
}
}
});
resolve(result);
})
.fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
})
});
}
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),
8 years ago
url: 'http://127.0.0.1:' + config.iguanaPort,
type: 'POST',
dataType: 'json'
})
.then(result => {
console.log(result);
resolve(result);
});
});
}
function checkAC(coinVal) {
if (coinVal == 'SUPERNET' ||
coinVal == 'REVS' ||
coinVal == 'WIRELESS' ||
coinVal == 'DEX' ||
coinVal == 'PANGEA' ||
coinVal == 'JUMBLR' ||
coinVal == 'BET' ||
coinVal == 'CRYPTO' ||
coinVal == 'HODL' ||
coinVal == 'SHARK' ||
coinVal == 'BOTS' ||
coinVal == 'MGW' ||
coinVal == 'MVP' ||
coinVal == 'KV' ||
coinVal == 'CEAL' ||
coinVal == 'MESH' ||
coinVal == 'USD' ||
coinVal == 'RON' ||
coinVal == 'EUR' ||
coinVal == 'JPY' ||
coinVal == 'GBP' ||
coinVal == 'AUD' ||
coinVal == 'CAD' ||
coinVal == 'CHF' ||
coinVal == 'NZD' ||
coinVal == 'CNY' ||
coinVal == 'RUB' ||
coinVal == 'MXN' ||
coinVal == 'BRL' ||
coinVal == 'INR' ||
coinVal == 'HKD' ||
coinVal == 'TRY' ||
coinVal == 'ZAR' ||
coinVal == 'PLN' ||
coinVal == 'NOK' ||
coinVal == 'SEK' ||
coinVal == 'DKK' ||
coinVal == 'CZK' ||
coinVal == 'HUF' ||
coinVal == 'ILS' ||
coinVal == 'KRW' ||
coinVal == 'MYR' ||
coinVal == 'PHP' ||
coinVal == 'SGD' ||
coinVal == 'THB' ||
coinVal == 'BGN' ||
coinVal == 'IDR' ||
coinVal == 'HRK') {
return true;
} else {
return false;
}
}
function formatBytes(bytes, decimals) {
if (bytes == 0)
return '0 Bytes';
var k = 1000,
dm = decimals + 1 || 3,
sizes = [
'Bytes',
'KB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB'
],
i = Math.floor(Math.log(bytes) / Math.log(k));
return {
'ramsize': parseFloat((bytes / Math.pow(k, i)).toFixed(dm)),
'size': sizes[i]
};
}