wallet_upload = function() {
try {
if(wallet_loadf.files.length != 1)
return;
var reader = new FileReader();
reader.onload = function(evt) {
try {
var resobj = JSON.parse(evt.target.result);
var privs = resobj;
var new_addrs = {};
for(var i= 0 ; i < privs.length ; i++) {
var reskey = parse_textprivkey(privs[i]);
new_addrs[reskey.address] = {'key':reskey, 'balance':null}
}
wallet_addrs = new_addrs;
wallet_reading = false;
walletUpdateBalancesInfo();
} catch(e) {
alert('Wallet loading failed.\nPlease make sure the file is valid and not corrupted.');
}
wallet_reading= false;
wallet_update_sendform();
wallet_update_info();
};
wallet_reading= true;
wallet_update_sendform();
wallet_update_info();
reader.readAsText(wallet_loadf.files.item(0));
} catch(e) {
alert('Wallet loading failed.\nPlease make sure the file is valid and not corrupted.');
wallet_reading= false;
wallet_update_sendform();
wallet_update_info();
}
}
wallet_download= function() {
var resprivkeys= [];
for(var k in wallet_addrs) {
if(wallet_addrs.hasOwnProperty(k))
resprivkeys.push(wallet_addrs[k].key.b58cprivkey);
}
var resJSON = resprivkeys;
var dlanchor = document.getElementById('wallet_dlanchor');
var datastr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(resJSON));
dlanchor.setAttribute("href", datastr);
dlanchor.setAttribute("download", "wallet.dat");
dlanchor.click();
}