+ clean blockchain data
* show sender wallet name and only show address in the main field
This commit is contained in:
8
main.js
8
main.js
@@ -66,9 +66,17 @@ locker.lock().then(function() {
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and require them here.
|
||||
// listen for request to get template
|
||||
|
||||
// get the template content from file
|
||||
ipcMain.on('getTemplateContent', (event, arg) => {
|
||||
event.returnValue = fs.readFileSync(path.join(app.getAppPath(), "assets/templates/") + arg, 'utf8');
|
||||
});
|
||||
|
||||
// quit the app on coomand
|
||||
ipcMain.on('appQuit', (event, arg) => {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
})
|
||||
.catch(function(err) {
|
||||
app.quit();
|
||||
|
||||
@@ -6,7 +6,9 @@ const os = require('os');
|
||||
|
||||
class Accounts {
|
||||
constructor() {
|
||||
this.getKeyStoreLocation = function() {
|
||||
}
|
||||
|
||||
getKeyStoreLocation() {
|
||||
switch(os.type()) {
|
||||
case "Darwin":
|
||||
return path.join(os.homedir(), 'Library', 'Ether1', 'keystore');
|
||||
@@ -15,7 +17,6 @@ class Accounts {
|
||||
return path.join(process.env.APPDATA, 'Ether1', 'keystore');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exportAccounts() {
|
||||
var savePath = dialog.showSaveDialog({
|
||||
@@ -23,7 +24,7 @@ class Accounts {
|
||||
});
|
||||
|
||||
if (savePath) {
|
||||
const accPath = this.getKeyStoreLocation();
|
||||
const accPath = EthoAccounts.getKeyStoreLocation();
|
||||
|
||||
fs.readdir(accPath, function(err, files) {
|
||||
var zip = new admZip();
|
||||
@@ -40,7 +41,7 @@ class Accounts {
|
||||
|
||||
importAccounts(accountsFile) {
|
||||
var extName = path.extname(accountsFile).toUpperCase();
|
||||
const accPath = this.getKeyStoreLocation();
|
||||
const accPath = EthoAccounts.getKeyStoreLocation();
|
||||
|
||||
if (extName == '.ZIP') {
|
||||
var zip = new admZip(accountsFile);
|
||||
@@ -57,7 +58,7 @@ class Accounts {
|
||||
}
|
||||
|
||||
saveAccount(account) {
|
||||
fs.writeFile(path.join(this.getKeyStoreLocation(), '0x' + account.address), JSON.stringify(account), 'utf8', function() {
|
||||
fs.writeFile(path.join(tEthoAccountshis.getKeyStoreLocation(), '0x' + account.address), JSON.stringify(account), 'utf8', function() {
|
||||
// file was written
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ const datastore = require('nedb');
|
||||
const moment = require('moment');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
|
||||
const dbPath = path.join(app.getPath('userData'), 'storage.db');
|
||||
const db = new datastore({ filename: dbPath });
|
||||
@@ -98,3 +99,33 @@ ipcMain.on('deleteWalletData', (event, arg) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('deleteBlockchainData', (event, arg) => {
|
||||
var deleteFolderRecursive = function(path) {
|
||||
if( fs.existsSync(path) ) {
|
||||
fs.readdirSync(path).forEach(function(file,index){
|
||||
var curPath = path + "/" + file;
|
||||
if(fs.lstatSync(curPath).isDirectory()) { // recurse
|
||||
deleteFolderRecursive(curPath);
|
||||
} else { // delete file
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
};
|
||||
|
||||
function getBlockchainDataLocation() {
|
||||
switch(os.type()) {
|
||||
case "Darwin":
|
||||
return path.join(os.homedir(), 'Library', 'Ether1', 'geth');
|
||||
break;
|
||||
default:
|
||||
return path.join(process.env.APPDATA, 'Ether1', 'geth');
|
||||
}
|
||||
}
|
||||
|
||||
// delete folder in a synchronous recursive maner
|
||||
deleteFolderRecursive(getBlockchainDataLocation());
|
||||
event.returnValue = true;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const {app, dialog, ipcMain} = require('electron');
|
||||
const child_process = require('child_process');
|
||||
const {app, dialog} = require('electron');
|
||||
const appRoot = require('app-root-path');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
@@ -79,4 +79,8 @@ class Geth {
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.on('stopGeth', (event, arg) => {
|
||||
EthoGeth.stopGeth();
|
||||
});
|
||||
|
||||
EthoGeth = new Geth();
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Ether1Wallet",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"description": "Desktop wallet for Ether1 currency",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -63,6 +63,12 @@ $(document).on("render_send", function() {
|
||||
$('select').formSelect( {classes: "fromAddressSelect"});
|
||||
|
||||
$("#sendFromAddress").on("change", function() {
|
||||
var optionText = $(this).find("option:selected").text();
|
||||
var addrName = optionText.substr(0, optionText.indexOf('-'));
|
||||
var addrValue = optionText.substr(optionText.indexOf("-") + 1);
|
||||
$(".fromAddressSelect input").val(addrValue.trim());
|
||||
$("#sendFromAddressName").html(addrName.trim());
|
||||
|
||||
web3Local.eth.getBalance(this.value, function(error, balance) {
|
||||
$("#sendMaxAmmount").html(parseFloat(web3Local.utils.fromWei(balance, 'ether')));
|
||||
});
|
||||
@@ -85,14 +91,6 @@ $(document).on("render_send", function() {
|
||||
$("#sendToAddressName").html(addressName);
|
||||
});
|
||||
|
||||
$("#sendFromAddress").off('change').on('change', function() {
|
||||
var optionText = $(this).find("option:selected").text();
|
||||
var addrName = optionText.substr(0, optionText.indexOf('-'));
|
||||
var addrValue = optionText.substr(optionText.indexOf("-") + 1);
|
||||
$(".fromAddressSelect input").val(addrValue.trim());
|
||||
$("#sendFromAddressName").html(addrName.trim());
|
||||
});
|
||||
|
||||
$("#btnLookForToAddress").off('click').on('click', function() {
|
||||
EthoBlockchain.getAddressListData(
|
||||
function(error) {
|
||||
|
||||
@@ -60,6 +60,8 @@ $(document).on("render_settings", function() {
|
||||
});
|
||||
|
||||
$("#btnSettingsCleanWallets").off('click').on('click', function() {
|
||||
EthoMainGUI.showGeneralConfirmation("Do you really want to delete wallets data?", function(result) {
|
||||
if (result) {
|
||||
ipcResult = ipcRenderer.sendSync('deleteWalletData', null);
|
||||
|
||||
if (ipcResult.success) {
|
||||
@@ -72,10 +74,32 @@ $(document).on("render_settings", function() {
|
||||
} else {
|
||||
EthoMainGUI.showGeneralError("Error clearing wallet names: " + ipcResult.error);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#btnSettingsCleanBlockchain").off('click').on('click', function() {
|
||||
EthoMainGUI.showGeneralError("Not implemented yet!");
|
||||
EthoMainGUI.showGeneralConfirmation("Do you really want to delete the blockchain data? Wallet will close and you will need to restart it!", function(result) {
|
||||
if (result) {
|
||||
var loading_screen = pleaseWait({
|
||||
logo: "assets/images/logo.png",
|
||||
backgroundColor: '#000000',
|
||||
loadingHtml: "<div class='spinner'><div class='bounce bounce1'></div><div class='bounce bounce2'></div><div class='bounce bounce3'></div></div><div class='loadingText'>Deleting blockchain data, wallet will automatically close, please wait...</div>"
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
// first stop the geth process
|
||||
ipcResult = ipcRenderer.send('stopGeth', null);
|
||||
|
||||
setTimeout(() => {
|
||||
// delete the blockchain date async and wait for 5 seconds
|
||||
ipcResult = ipcRenderer.sendSync('deleteBlockchainData', null);
|
||||
// finally quit the application
|
||||
ipcResult = ipcRenderer.send('appQuit', null);
|
||||
}, 5000);
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user