+ 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
|
// 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.
|
// code. You can also put them in separate files and require them here.
|
||||||
// listen for request to get template
|
// listen for request to get template
|
||||||
|
|
||||||
|
// get the template content from file
|
||||||
ipcMain.on('getTemplateContent', (event, arg) => {
|
ipcMain.on('getTemplateContent', (event, arg) => {
|
||||||
event.returnValue = fs.readFileSync(path.join(app.getAppPath(), "assets/templates/") + arg, 'utf8');
|
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) {
|
.catch(function(err) {
|
||||||
app.quit();
|
app.quit();
|
||||||
|
|||||||
@@ -6,15 +6,16 @@ const os = require('os');
|
|||||||
|
|
||||||
class Accounts {
|
class Accounts {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.getKeyStoreLocation = function() {
|
}
|
||||||
switch(os.type()) {
|
|
||||||
case "Darwin":
|
getKeyStoreLocation() {
|
||||||
return path.join(os.homedir(), 'Library', 'Ether1', 'keystore');
|
switch(os.type()) {
|
||||||
break;
|
case "Darwin":
|
||||||
default:
|
return path.join(os.homedir(), 'Library', 'Ether1', 'keystore');
|
||||||
return path.join(process.env.APPDATA, 'Ether1', 'keystore');
|
break;
|
||||||
}
|
default:
|
||||||
}
|
return path.join(process.env.APPDATA, 'Ether1', 'keystore');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exportAccounts() {
|
exportAccounts() {
|
||||||
@@ -23,7 +24,7 @@ class Accounts {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (savePath) {
|
if (savePath) {
|
||||||
const accPath = this.getKeyStoreLocation();
|
const accPath = EthoAccounts.getKeyStoreLocation();
|
||||||
|
|
||||||
fs.readdir(accPath, function(err, files) {
|
fs.readdir(accPath, function(err, files) {
|
||||||
var zip = new admZip();
|
var zip = new admZip();
|
||||||
@@ -40,7 +41,7 @@ class Accounts {
|
|||||||
|
|
||||||
importAccounts(accountsFile) {
|
importAccounts(accountsFile) {
|
||||||
var extName = path.extname(accountsFile).toUpperCase();
|
var extName = path.extname(accountsFile).toUpperCase();
|
||||||
const accPath = this.getKeyStoreLocation();
|
const accPath = EthoAccounts.getKeyStoreLocation();
|
||||||
|
|
||||||
if (extName == '.ZIP') {
|
if (extName == '.ZIP') {
|
||||||
var zip = new admZip(accountsFile);
|
var zip = new admZip(accountsFile);
|
||||||
@@ -57,7 +58,7 @@ class Accounts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveAccount(account) {
|
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
|
// file was written
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const datastore = require('nedb');
|
|||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
const dbPath = path.join(app.getPath('userData'), 'storage.db');
|
const dbPath = path.join(app.getPath('userData'), 'storage.db');
|
||||||
const db = new datastore({ filename: dbPath });
|
const db = new datastore({ filename: dbPath });
|
||||||
@@ -96,5 +97,35 @@ ipcMain.on('deleteWalletData', (event, arg) => {
|
|||||||
} else {
|
} else {
|
||||||
event.returnValue = { success: true, error: null };
|
event.returnValue = { success: true, error: null };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 child_process = require('child_process');
|
||||||
const {app, dialog} = require('electron');
|
|
||||||
const appRoot = require('app-root-path');
|
const appRoot = require('app-root-path');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
@@ -79,4 +79,8 @@ class Geth {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipcMain.on('stopGeth', (event, arg) => {
|
||||||
|
EthoGeth.stopGeth();
|
||||||
|
});
|
||||||
|
|
||||||
EthoGeth = new Geth();
|
EthoGeth = new Geth();
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Ether1Wallet",
|
"name": "Ether1Wallet",
|
||||||
"version": "0.2.5",
|
"version": "0.2.6",
|
||||||
"description": "Desktop wallet for Ether1 currency",
|
"description": "Desktop wallet for Ether1 currency",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ $(document).on("render_send", function() {
|
|||||||
$('select').formSelect( {classes: "fromAddressSelect"});
|
$('select').formSelect( {classes: "fromAddressSelect"});
|
||||||
|
|
||||||
$("#sendFromAddress").on("change", function() {
|
$("#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) {
|
web3Local.eth.getBalance(this.value, function(error, balance) {
|
||||||
$("#sendMaxAmmount").html(parseFloat(web3Local.utils.fromWei(balance, 'ether')));
|
$("#sendMaxAmmount").html(parseFloat(web3Local.utils.fromWei(balance, 'ether')));
|
||||||
});
|
});
|
||||||
@@ -85,14 +91,6 @@ $(document).on("render_send", function() {
|
|||||||
$("#sendToAddressName").html(addressName);
|
$("#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() {
|
$("#btnLookForToAddress").off('click').on('click', function() {
|
||||||
EthoBlockchain.getAddressListData(
|
EthoBlockchain.getAddressListData(
|
||||||
function(error) {
|
function(error) {
|
||||||
|
|||||||
@@ -60,22 +60,46 @@ $(document).on("render_settings", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#btnSettingsCleanWallets").off('click').on('click', function() {
|
$("#btnSettingsCleanWallets").off('click').on('click', function() {
|
||||||
ipcResult = ipcRenderer.sendSync('deleteWalletData', null);
|
EthoMainGUI.showGeneralConfirmation("Do you really want to delete wallets data?", function(result) {
|
||||||
|
if (result) {
|
||||||
|
ipcResult = ipcRenderer.sendSync('deleteWalletData', null);
|
||||||
|
|
||||||
if (ipcResult.success) {
|
if (ipcResult.success) {
|
||||||
iziToast.success({
|
iziToast.success({
|
||||||
title: 'Success',
|
title: 'Success',
|
||||||
message: 'Wallet names were succesfully cleaned',
|
message: 'Wallet names were succesfully cleaned',
|
||||||
position: 'topRight',
|
position: 'topRight',
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
EthoMainGUI.showGeneralError("Error clearing wallet names: " + ipcResult.error);
|
EthoMainGUI.showGeneralError("Error clearing wallet names: " + ipcResult.error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#btnSettingsCleanBlockchain").off('click').on('click', function() {
|
$("#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