+ import from private key added
This commit is contained in:
@@ -89,6 +89,14 @@
|
|||||||
<label for="inputPrivateKey">Private Key:</label>
|
<label for="inputPrivateKey">Private Key:</label>
|
||||||
<input type="password" class="form-control" id="inputPrivateKey">
|
<input type="password" class="form-control" id="inputPrivateKey">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="walletPasswordSecond">Account Password:</label>
|
||||||
|
<input type="password" class="form-control" id="keyPasswordFirst">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="walletPasswordSecond">Confirm Password:</label>
|
||||||
|
<input type="password" class="form-control" id="keyPasswordSecond">
|
||||||
|
</div>
|
||||||
<button type="button" class="btn btn-etho btn-dialog-confirm" id="btnImportFromPrivateKeyConfirm">Import</button>
|
<button type="button" class="btn btn-etho btn-dialog-confirm" id="btnImportFromPrivateKeyConfirm">Import</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -213,10 +213,14 @@ class Blockchain {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
importFromPrivateKey(privateKey, password) {
|
importFromPrivateKey(privateKey, keyPassword, clbError, clbSuccess) {
|
||||||
web3Local.eth.accounts.wallet.clear();
|
web3Local.eth.personal.importRawKey(privateKey, keyPassword, function (error, account) {
|
||||||
web3Local.eth.accounts.wallet.add(privateKey);
|
if (error) {
|
||||||
return web3Local.eth.accounts.wallet.encrypt("123456789");
|
clbError(error);
|
||||||
|
} else {
|
||||||
|
clbSuccess(account);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
subsribePendingTransactions(clbError, clbSuccess, clbData) {
|
subsribePendingTransactions(clbError, clbSuccess, clbData) {
|
||||||
|
|||||||
@@ -70,6 +70,34 @@ class Wallets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateImportFromKeyForm() {
|
||||||
|
if (EthoMainGUI.getAppState() == "account") {
|
||||||
|
if (!$("#inputPrivateKey").val()) {
|
||||||
|
EthoMainGUI.showGeneralError("Private key cannot be empty!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$("#keyPasswordFirst").val()) {
|
||||||
|
EthoMainGUI.showGeneralError("Password cannot be empty!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$("#keyPasswordSecond").val()) {
|
||||||
|
EthoMainGUI.showGeneralError("Password cannot be empty!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($("#keyPasswordFirst").val() !== $("#keyPasswordSecond").val()) {
|
||||||
|
EthoMainGUI.showGeneralError("Passwords do not match!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderWalletsState() {
|
renderWalletsState() {
|
||||||
// clear the list of addresses
|
// clear the list of addresses
|
||||||
EthoWallets.clearAddressList();
|
EthoWallets.clearAddressList();
|
||||||
@@ -193,16 +221,19 @@ $(document).on("render_wallets", function () {
|
|||||||
$("#dlgImportFromPrivateKey").iziModal("open");
|
$("#dlgImportFromPrivateKey").iziModal("open");
|
||||||
|
|
||||||
function doImportFromPrivateKeys() {
|
function doImportFromPrivateKeys() {
|
||||||
var account = EthoBlockchain.importFromPrivateKey($("#inputPrivateKey").val());
|
|
||||||
$("#dlgImportFromPrivateKey").iziModal("close");
|
$("#dlgImportFromPrivateKey").iziModal("close");
|
||||||
|
|
||||||
if (account) {
|
if (EthoWallets.validateImportFromKeyForm()) {
|
||||||
ipcRenderer.sendSync("saveAccount", account[0]);
|
var account = EthoBlockchain.importFromPrivateKey($("#inputPrivateKey").val(), $("#keyPasswordFirst").val(), function (error) {
|
||||||
EthoWallets.renderWalletsState();
|
EthoMainGUI.showGeneralError(error);
|
||||||
|
}, function (account) {
|
||||||
iziToast.success({title: "Imported", message: "Account was succesfully imported", position: "topRight", timeout: 2000});
|
if (account) {
|
||||||
} else {
|
EthoWallets.renderWalletsState();
|
||||||
EthoMainGUI.showGeneralError("Error importing account from private key!");
|
iziToast.success({title: "Imported", message: "Account was succesfully imported", position: "topRight", timeout: 2000});
|
||||||
|
} else {
|
||||||
|
EthoMainGUI.showGeneralError("Error importing account from private key!");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user