-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenroll.html
232 lines (176 loc) · 6.27 KB
/
enroll.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="semantic/dist/semantic.css">
<style type="text/css">
body {
background-color: #FFFFFF;
}
.ui.menu .item img.logo {
margin-right: 1.5em;
}
.main.container {
margin-top: 7em;
}
.ui.footer.segment {
margin: 5em 0em 0em;
padding: 5em 0em;
}
</style>
<title>Enroll | Atlaschain</title>
<script src="dist/lightwallet.min.js"></script>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="semantic/dist/semantic.min.js"></script>
<script src="node_modules/lodash/lodash.js"></script>
<script src="node_modules/async/lib/async.js"></script>
<script src="node_modules/storejs/dist/store.js"></script>
<script src="assets/mymail-crypt-util.js"></script>
<script src="assets/openpgp.js"></script>
<script src="node_modules/web3/dist/web3.js"></script>
<script src="node_modules/hooked-web3-provider/build/hooked-web3-provider.js"></script>
<script src="assets/app.js"></script>
<script src="assets/commander.js"></script>
<script>
var global_keystore;
jQuery(document).ready(function() {
var web3 = new Web3();
var global_keystore;
function setWeb3Provider(keystore) {
var web3Provider = new HookedWeb3Provider({
host: "http://eth.lightrains.com",
transaction_signer: keystore
});
web3.setProvider(web3Provider);
}
function newAddresses(password) {
if (password == '') {
password = prompt('Enter password to retrieve addresses', 'Password');
}
var numAddr = 1
lightwallet.keystore.deriveKeyFromPassword(password, function(err, pwDerivedKey) {
global_keystore.generateNewAddress(pwDerivedKey, numAddr);
var addresses = global_keystore.getAddresses();
getBalances();
})
}
function getBalances() {
var addresses = global_keystore.getAddresses();
var lastAddress = addresses[0];
sendEth(lastAddress);
document.getElementById('addr').innerHTML = 'Retrieving address...'
async.map(addresses, web3.eth.getBalance, function(err, balances) {
async.map(addresses, web3.eth.getTransactionCount, function(err, nonces) {
document.getElementById('addr').innerHTML = ''
for (var i=0; i<addresses.length; ++i) {
document.getElementById('addr').innerHTML += addresses[i]
}
})
})
}
function newWallet() {
var extraEntropy = '';
var randomSeed = lightwallet.keystore.generateRandomSeed(extraEntropy);
var infoString = 'Your new wallet seed is: "' + randomSeed +
'". Please write it down on paper or in a password manager, you will need it to access your wallet. Do not let anyone see this seed or they can take your Ether. ' +
'Please enter a password to encrypt your seed while in the browser.'
var password = prompt(infoString, 'Password');
lightwallet.keystore.deriveKeyFromPassword(password, function(err, pwDerivedKey) {
global_keystore = new lightwallet.keystore(
randomSeed,
pwDerivedKey);
newAddresses(password);
setWeb3Provider(global_keystore);
})
}
function sendEth(lastAddress) {
var fromAddr = web3.eth.coinbase
var toAddr = lastAddress
var valueEth = 5
var value = parseFloat(valueEth)*1.0e18
var gasPrice = 50000000000
var gas = 50000
web3.eth.sendTransaction({from: fromAddr, to: toAddr, value: value, gasPrice: gasPrice, gas: gas}, function (err, txhash) {
console.log('error: ' + err)
console.log('txhash: ' + txhash)
updateBalances();
})
}
function updateBalances() {
$('#addProfile').removeClass('loading');
}
$('#enroll').click(function() {
window.location = 'map.html';
});
parsePublicKeys();
// parsePrivateKeys();
});
</script>
</head>
<body>
<div class="ui fixed menu">
<div class="ui container">
<a href="index.html" class="header item">
<img class="logo" src="assets/atlaschain-square.png">
Atlaschain
</a>
<a href="index.html" class="item">Home</a>
<a href="index.html" class="item">Start Now</a>
<a href="map.html" class="item">Interface</a>
<a href="admin.html" class="item">Administrator</a>
</div>
</div>
<div class="ui main container">
<div class="ui ordered steps">
<div class="completed step">
<div class="content">
<div class="title">Keys</div>
<div class="description">Create your encryption keys</div>
</div>
</div>
<div class="completed step">
<div class="content">
<div class="title">Wallet</div>
<div class="description">Create Atlaschain Wallet</div>
</div>
</div>
<a class="active step">
<i class="ticket icon"></i>
<div class="content">
<div class="title">Enroll</div>
<div class="description">Enroll Atlaschain</div>
</div>
</a>
</div>
<div class="ui center aligned container">
<div class="ui hidden divider"></div>
<div class="ui hidden divider"></div>
<div class="ui hidden divider"></div>
<div class="ui hidden divider"></div>
<div class="ui hidden divider"></div>
<button class="ui button big green" id="enroll" >Enroll</button>
</div>
</div>
<div class="ui inverted vertical footer segment">
<div class="ui center aligned container">
<div class="ui stackable inverted divided grid">
<div class="three wide column">
<h4 class="ui inverted header">Group 1</h4>
<div class="ui inverted link list">
<a href="#" class="item">Link One</a>
<a href="#" class="item">Link Two</a>
<a href="#" class="item">Link Three</a>
<a href="#" class="item">Link Four</a>
</div>
</div>
<div class="seven wide column">
<h4 class="ui inverted header">Footer Header</h4>
<p>Extra space for a call to action inside the footer that could help re-engage users.</p>
</div>
</div>
</div>
</div>
</body>
</html>