Functional Keystore Unlock - ethoFS Uploads
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<head>
|
||||
<!-- Google Fonts -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic-ext" rel="stylesheet" type="text/css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic-ext" rel="stylesheet"
|
||||
type="text/css">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css">
|
||||
<!-- Bootstrap Core Css -->
|
||||
<!--<link href="assets/dashboard/plugins/bootstrap/css/bootstrap.css" rel="stylesheet">-->
|
||||
@@ -12,7 +13,8 @@
|
||||
<link href="assets/dashboard/plugins/morrisjs/morris.css" rel="stylesheet" />-->
|
||||
<!-- Custom Css -->
|
||||
<link href="assets/dashboard/css/style.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css">
|
||||
<link rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css">
|
||||
<!-- AdminBSB Themes. You can choose a theme from css/themes instead of get all themes -->
|
||||
<link href="assets/dashboard/css/themes/all-themes.css" rel="stylesheet" />
|
||||
<script src="https://medium-widget.pixelpoint.io/widget.js"></script>
|
||||
@@ -128,11 +130,13 @@
|
||||
|
||||
</div>
|
||||
<center>
|
||||
<button type="button" class="btn bg-indigo waves-effect" id="main-upload-button" style="margin: 10px; display:inline-block;">
|
||||
<button type="button" class="btn bg-indigo waves-effect" id="main-upload-button"
|
||||
style="margin: 10px; display:inline-block;">
|
||||
<i class="material-icons">cloud_upload</i>
|
||||
<span>Upload to ethoFS</span>
|
||||
</button>
|
||||
<button type="button" class="btn bg-indigo waves-effect" id="main-login-button" style="margin: 10px; display:inline-block;">
|
||||
<button type="button" class="btn bg-indigo waves-effect" id="main-login-button"
|
||||
style="margin: 10px; display:inline-block;">
|
||||
<i class="material-icons">fingerprint</i>
|
||||
<span id="ethofs-login-button-text">Login To ethoFS</span>
|
||||
</button>
|
||||
@@ -188,15 +192,36 @@
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body" style="width:100%; background: #000000; background-color: #000;">
|
||||
<p>ethoFS Account Address Not Found - Please Install/Login To a Browser Extension or Login
|
||||
With Private Key Below</p>
|
||||
<table class="rwd-table">
|
||||
<p>ethoFS Account Address Not Found - Please Login
|
||||
With Wallet/Private Key Below</p>
|
||||
|
||||
<div class="input-field col s6">
|
||||
<select id="sendFromAddress" style="background-color:White;">
|
||||
</select>
|
||||
<label for="sendFromAddress">Wallet:</label>
|
||||
<small id="sendFromAddressName" class="form-text text-muted"></small>
|
||||
<small id="sendFromAddressValue" class="form-text text-muted"></small>
|
||||
</div>
|
||||
|
||||
<table class="rwd-table" id="privatekeytable">
|
||||
<tr style="border-color:#000;">
|
||||
<th>Private Key:</th>
|
||||
</tr>
|
||||
<tr style="border-color:#000;">
|
||||
<td data-th="Private Key">
|
||||
<input type="text" id="privatekey" name="privatekey" placeholder="Enter Private Key" style="color:White;">
|
||||
<input type="text" id="privatekey" name="privatekey" placeholder="Enter Private Key"
|
||||
style="color:White;">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="rwd-table" id="walletpasswordtable">
|
||||
<tr style="border-color:#000;">
|
||||
<th>Wallet Password:</th>
|
||||
</tr>
|
||||
<tr style="border-color:#000;">
|
||||
<td data-th="Wallet Password">
|
||||
<input type="text" id="walletpassword" name="walletpassword" placeholder="Enter Wallet Password"
|
||||
style="color:White;">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -236,7 +261,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer" style="background-color: #840032;">
|
||||
<button type="button" class="btn btn-link waves-effect" data-dismiss="modal" id="ethofs-registration-button">REGISTER</button>
|
||||
<button type="button" class="btn btn-link waves-effect" data-dismiss="modal"
|
||||
id="ethofs-registration-button">REGISTER</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -307,7 +333,8 @@
|
||||
box to upload.
|
||||
</p>
|
||||
</center>
|
||||
<input type="file" id="fileUploadButton" webkitdirectory="true" mozdirectory="true" msdirectory="true" odirectory="true" directory="true" multiple="true">
|
||||
<input type="file" id="fileUploadButton" webkitdirectory="true" mozdirectory="true" msdirectory="true"
|
||||
odirectory="true" directory="true" multiple="true">
|
||||
</div>
|
||||
<div id="progress-container">
|
||||
<div id="progress-bar"></div>
|
||||
@@ -348,7 +375,8 @@
|
||||
</tr>
|
||||
<tr style="border-color:#000;">
|
||||
<td data-th="Contract Name">
|
||||
<input type="text" id="newcontractname" name="newcontractname" placeholder="Enter Contract Name" style="color:white;">
|
||||
<input type="text" id="newcontractname" name="newcontractname" placeholder="Enter Contract Name"
|
||||
style="color:white;">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -421,24 +449,29 @@
|
||||
<h3 style="padding-left:10px;">Message Log:</h3>
|
||||
<span class="upload-message" style="color: #3CB371; font-size: 24px; padding: 10px"></span>
|
||||
</div>
|
||||
<div class="summary" style="text-align: center !important; padding: 10px; width:100%; background: #000000;">
|
||||
<div class="summary"
|
||||
style="text-align: center !important; padding: 10px; width:100%; background: #000000;">
|
||||
<div id="myBar">0%</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<div class="modal-footer" style="background-color: #840032; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color:#000">
|
||||
<button type="button" class="btn btn-primary" id="upload-check-button" onclick="event.stopPropagation();">Close</button>
|
||||
<div class="modal-footer"
|
||||
style="background-color: #840032; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color:#000">
|
||||
<button type="button" class="btn btn-primary" id="upload-check-button"
|
||||
onclick="event.stopPropagation();">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="analyzeDataModal" tabindex="-1" role="dialog" aria-labelledby="staticModalLabel" aria-hidden="true" data-backdrop="static">
|
||||
<div class="modal fade" id="analyzeDataModal" tabindex="-1" role="dialog" aria-labelledby="staticModalLabel"
|
||||
aria-hidden="true" data-backdrop="static">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content" style="background-color: #840032;">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="defaultModalLabel" style="color:white;">
|
||||
<button type="button" class="close" data-dismiss="modal" id="analyze-close-button" aria-label="Close" style="color:#ffffff;">
|
||||
<button type="button" class="close" data-dismiss="modal" id="analyze-close-button" aria-label="Close"
|
||||
style="color:#ffffff;">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<br>
|
||||
@@ -458,14 +491,17 @@
|
||||
<h4 style="padding-left:10px;">Message Log:</h4>
|
||||
<pre class="analyze-message" style="color: #3CB371; font-size: 24px;"></pre>
|
||||
</div>
|
||||
<div class="summary" style="text-align: center !important; padding: 10px; width:100%; background: #000000;">
|
||||
<div class="summary"
|
||||
style="text-align: center !important; padding: 10px; width:100%; background: #000000;">
|
||||
<div id="myAnalyzeBar">0%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal-footer" style="background-color: #840032; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color:#000">
|
||||
<button type="button" class="btn btn-primary" id="upload-check-button" onclick="event.stopPropagation();">Close</button>
|
||||
<div class="modal-footer"
|
||||
style="background-color: #840032; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color:#000">
|
||||
<button type="button" class="btn btn-primary" id="upload-check-button"
|
||||
onclick="event.stopPropagation();">Close</button>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
@@ -475,7 +511,8 @@
|
||||
<!-- end analyze data modal -->
|
||||
|
||||
<!-- begin mined block checking modal -->
|
||||
<div class="modal fade" id="minedBlockTrackerModal" tabindex="-1" role="dialog" aria-labelledby="staticModalLabel" aria-hidden="true" data-backdrop="static">
|
||||
<div class="modal fade" id="minedBlockTrackerModal" tabindex="-1" role="dialog" aria-labelledby="staticModalLabel"
|
||||
aria-hidden="true" data-backdrop="static">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content" style="background-color: #840032;">
|
||||
<div class="modal-header">
|
||||
@@ -490,7 +527,8 @@
|
||||
<main>
|
||||
<div class="box node" style="width:100%; background: #000000; background-color: #000;">
|
||||
<h3 style="padding: 20px;">Ether-1 Transaction Status:
|
||||
<span id="mining-status-message" style="color: #3CB371; font-size: 24px; text-align: center !important;">In
|
||||
<span id="mining-status-message"
|
||||
style="color: #3CB371; font-size: 24px; text-align: center !important;">In
|
||||
Progress</span>
|
||||
</h3>
|
||||
<div>
|
||||
@@ -499,7 +537,8 @@
|
||||
<span class="mining-message" id="mining-message" style="color: #3CB371; font-size: 24px;"></span>
|
||||
</center>
|
||||
</div>
|
||||
<div class="summary" style="text-align: center !important; padding: 20px; width:100%; background: #000000;">
|
||||
<div class="summary"
|
||||
style="text-align: center !important; padding: 20px; width:100%; background: #000000;">
|
||||
<h3 style="font-size: 24px;">Current Ether-1 Block Height:
|
||||
      
|
||||
<span id="block-height" style="color: #3CB371; font-size: 24px;">0</span>
|
||||
@@ -514,7 +553,8 @@
|
||||
<!-- end mined block checking modal -->
|
||||
|
||||
<!-- begin preparing upload modal -->
|
||||
<div class="modal fade" id="preparingUploadModal" tabindex="-1" role="dialog" aria-labelledby="staticModalLabel" aria-hidden="true" data-backdrop="static">
|
||||
<div class="modal fade" id="preparingUploadModal" tabindex="-1" role="dialog" aria-labelledby="staticModalLabel"
|
||||
aria-hidden="true" data-backdrop="static">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content" style="background-color: #840032;">
|
||||
<div class="modal-header">
|
||||
@@ -657,7 +697,8 @@
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<div class="modal-footer" style="background-color: #840032; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color:#000">
|
||||
<div class="modal-footer"
|
||||
style="background-color: #840032; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color:#000">
|
||||
<div class="row clearfix">
|
||||
<button class="btn btn-primary" id="contract-extension-button" type="button">Extend Hosting
|
||||
Contract</button>
|
||||
|
||||
5
main.js
5
main.js
@@ -23,7 +23,10 @@ locker.lock().then(function() {
|
||||
minWidth: 1100,
|
||||
minHeight: 700,
|
||||
backgroundColor: "#000000",
|
||||
icon: "assets/images/icon.png"
|
||||
icon: "assets/images/icon.png",
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
});
|
||||
|
||||
// and load the index.html of the app.
|
||||
|
||||
1319
package-lock.json
generated
1319
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -59,20 +59,23 @@
|
||||
"adm-zip": "^0.4.13",
|
||||
"app-root-path": "^2.1.0",
|
||||
"electron-storage": "^1.0.7",
|
||||
"ethereum-private-key-to-address": "0.0.2",
|
||||
"ethereumjs-common": "^1.3.2",
|
||||
"fs-extra": "^7.0.1",
|
||||
"handlebars": ">=4.1.2",
|
||||
"keythereum-node": "^2.0.0",
|
||||
"moment": "^2.23.0",
|
||||
"nedb": "^1.8.0",
|
||||
"single-instance": "0.0.1",
|
||||
"ethereumjs-common": "^1.3.2",
|
||||
"node-fetch": "^2.6.0",
|
||||
"node-gyp": "^6.0.0",
|
||||
"pull-file-reader": "^1.0.2",
|
||||
"single-instance": "0.0.1",
|
||||
"web3": "^1.2.1",
|
||||
"ethereum-private-key-to-address": "0.0.2"
|
||||
"keythereum": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.5.0",
|
||||
"electron": "^3.0.12",
|
||||
"electron": "^3.1.13",
|
||||
"electron-builder": "^20.38.3",
|
||||
"ethereum-private-key-to-address": "0.0.2",
|
||||
"ethereumjs-common": "^1.3.2",
|
||||
@@ -83,6 +86,7 @@
|
||||
"pull-file-reader": "^1.0.2",
|
||||
"unibeautify": "^0.17.0",
|
||||
"unibeautify-cli": "^0.2.1",
|
||||
"web3": "^1.2.1"
|
||||
"web3": "^1.2.1",
|
||||
"keythereum": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,15 @@ const {
|
||||
ipcRenderer
|
||||
} = require("electron");
|
||||
const privateKeyToAddress = require('ethereum-private-key-to-address');
|
||||
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
const Buf = require('buffer').Buffer;
|
||||
const Common = require('ethereumjs-common');
|
||||
const fetch = require("node-fetch");
|
||||
const fs = require('fs');
|
||||
|
||||
const fileReaderPullStream = require('pull-file-reader')
|
||||
const request = require('request');
|
||||
const keythereum = require("keythereum");
|
||||
|
||||
// Node
|
||||
var $ethomessage;
|
||||
@@ -53,6 +54,7 @@ var $miningMessage;
|
||||
|
||||
/*START OF MISC GLOBAL VARIABLES*/
|
||||
|
||||
var loginAddress;
|
||||
var privateKeyLogin = false;
|
||||
var GlobalPrivateKey;
|
||||
var minimumContractCost = 10000000000000000;
|
||||
@@ -129,8 +131,6 @@ class Uploads {
|
||||
}
|
||||
web3 = new Web3()
|
||||
web3.setProvider(new Web3.providers.WebsocketProvider("ws://localhost:8546"));
|
||||
$('#ethofsLoginModal').iziModal();
|
||||
$('#ethofsLoginModal').iziModal('open');
|
||||
} else {
|
||||
EthoUploads.ethofsLogin(GlobalPrivateKey);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ class Uploads {
|
||||
web3.eth.net.isListening()
|
||||
.then(function () {
|
||||
console.log('ethoFS is connected')
|
||||
let account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
|
||||
var account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
|
||||
console.log(account);
|
||||
web3.eth.accounts.wallet.add(account)
|
||||
web3.eth.defaultAccount = account.address;
|
||||
@@ -1407,7 +1407,8 @@ EthoUploads = new Uploads();
|
||||
|
||||
|
||||
$(document).on("render_uploads", function () {
|
||||
|
||||
$('#privatekeytable').hide();
|
||||
$('#walletpasswordtable').hide();
|
||||
// Misc
|
||||
$ethomessage = document.querySelector('.etho-message')
|
||||
$nodeId = document.querySelector('.node-id')
|
||||
@@ -1442,10 +1443,73 @@ $(document).on("render_uploads", function () {
|
||||
$(document).on("click", "#main-login-button", function (event) {
|
||||
GlobalPrivateKey = switchFlag;
|
||||
EthoUploads.checkLogin();
|
||||
|
||||
$('#ethofsLoginModal').iziModal({
|
||||
onOpened: function () {
|
||||
console.log("Login Setup Opened ..");
|
||||
var addressBook = EthoDatatabse.getWallets();
|
||||
console.log("Getting Address List...");
|
||||
|
||||
$('#sendFromAddress').empty();
|
||||
$('#sendFromAddress').append(new Option('Login With Private Key', 'privatekey'))
|
||||
$('#privatekeytable').show();
|
||||
var option = $(this).find("option:selected").text();
|
||||
$("#sendFromAddressName").html(option.trim());
|
||||
|
||||
for (var key in addressBook.names) {
|
||||
if (addressBook.names.hasOwnProperty(key)) {
|
||||
$('#sendFromAddress').append(new Option(addressBook.names[key], key))
|
||||
}
|
||||
}
|
||||
|
||||
$("#sendFromAddress").on("change", function () {
|
||||
var optionText = $(this).find("option:selected").text();
|
||||
var optionTextValue = $(this).find("option:selected").val();
|
||||
$("#sendFromAddressName").html(optionText.trim());
|
||||
console.log("Address Name: " + optionText)
|
||||
console.log("Address: " + optionText)
|
||||
if (optionTextValue == 'privatekey') {
|
||||
privateKeyLogin = true;
|
||||
$("#sendFromAddressValue").hide();
|
||||
$('#walletpasswordtable').hide();
|
||||
$('#privatekeytable').show();
|
||||
} else {
|
||||
privateKeyLogin = false;
|
||||
$("#sendFromAddressValue").show();
|
||||
$('#privatekeytable').hide();
|
||||
$('#walletpasswordtable').show();
|
||||
$("#sendFromAddressValue").html(optionTextValue.trim());
|
||||
loginAddress = optionTextValue.trim();
|
||||
}
|
||||
});
|
||||
},
|
||||
onOpening: function (modal) {
|
||||
console.log("Opening Login Setup..");
|
||||
$("#sendFromAddressValue").hide();
|
||||
$('#walletpasswordtable').hide();
|
||||
$('#privatekeytable').hide();
|
||||
}
|
||||
});
|
||||
$('#ethofsLoginModal').iziModal('open');
|
||||
});
|
||||
|
||||
$(document).on("click", "#ethofs-login-button", function (event) {
|
||||
EthoUploads.ethofsLogin(document.getElementById('privatekey').value);
|
||||
if (privateKeyLogin == true) {
|
||||
GlobalPrivateKey = document.getElementById('privatekey').value;
|
||||
console.log("Global Private Key: " + GlobalPrivateKey);
|
||||
EthoUploads.ethofsLogin(GlobalPrivateKey);
|
||||
} else {
|
||||
loginPassword = document.getElementById('walletpassword').value;
|
||||
loginAddress = $("#sendFromAddress").find("option:selected").val().trim();
|
||||
var accountsPath = getKeyStoreLocation();
|
||||
var keyObject = keythereum.importFromFile(loginAddress, accountsPath);
|
||||
var privateKey = keythereum.recover(loginPassword, keyObject);
|
||||
var key = privateKey.toString('hex');
|
||||
GlobalPrivateKey = key;
|
||||
console.log("Global Private Key: " + GlobalPrivateKey);
|
||||
EthoUploads.ethofsLogin(GlobalPrivateKey);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(document).on("click", "#main-upload-button", function (event) {
|
||||
@@ -1460,19 +1524,6 @@ $(document).on("render_uploads", function () {
|
||||
EthoUploads.resetUploadModal();
|
||||
});
|
||||
|
||||
/*$("#defaultModal1").on("close", function () {
|
||||
EthoUploads.resetUploadSystem();
|
||||
EthoUploads.resetUploadModal();
|
||||
});
|
||||
$("#defaultModal2").on("close", function () {
|
||||
EthoUploads.resetUploadSystem();
|
||||
EthoUploads.resetUploadModal();
|
||||
});
|
||||
$("#defaultModal3").on("close", function () {
|
||||
EthoUploads.resetUploadSystem();
|
||||
EthoUploads.resetUploadModal();
|
||||
});*/
|
||||
|
||||
$(document).on("click", "#defaultModal-next", function (event) {
|
||||
$('#defaultModal2').iziModal();
|
||||
$('#defaultModal2').iziModal('open');
|
||||
@@ -1545,3 +1596,13 @@ $(document).on("render_uploads", function () {
|
||||
document.getElementById("ethoprice").textContent = EthoUploads.round(ethoPriceUSD, 4);
|
||||
}).catch(err => {});
|
||||
});
|
||||
|
||||
function getKeyStoreLocation() {
|
||||
switch (os.type()) {
|
||||
case "Darwin":
|
||||
return path.join(os.homedir(), "Library", "Ether1");
|
||||
break;
|
||||
default:
|
||||
return path.join(process.env.APPDATA, "Ether1");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user