forked from RecordsKeeper/recordskeeper-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateKey.html
executable file
·316 lines (279 loc) · 12.4 KB
/
generateKey.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Vault0x</title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="theme-color" content="#212739">
<meta name="MobileOptimized" content="320">
<meta name="HandheldFriendly" content="true">
<meta name="viewport" content="width=device-width, initial-scale=1, target-densitydpi=device-dpi">
<meta name="author" content="http://psdhtml.me">
<link rel="stylesheet" media="screen" href="styles/screen.css">
<link rel="stylesheet" media="print" href="styles/print.css">
<link rel="icon" type="image/x-icon" href="favicon.png">
<meta property="og:title" content="">
<meta property="og:type" content="website">
<meta property="og:description" content=".">
<meta property="og:site_name" content="">
<meta property="og:url" content="">
<meta property="og:image" content="">
<script type='application/ld+json'>
{
"@context": "http://schema.org/",
"@type": "Organization",
"url": "",
"name": "Vault0x",
"legalName": "Vault0x",
"description": "",
"logo": "",
"image": "",
"author": "psdHTML.me",
"contactPoint": {
"@type": "ContactPoint",
"contactType": "Customer service",
"telephone": ""
},
"address": {
"@type": "PostalAddress",
"streetAddress": "",
"addressLocality": "",
"addressRegion": "",
"postalCode": "",
"addressCountry": ""
}
}
</script>
</head>
<body>
<div id="root">
<header id="top">
<p id="logo"><a href="./" accesskey="h">Vault0x</a></p>
<nav id="skip">
<ul>
<li><a href="#nav" accesskey="n">Skip to Navigation (n)</a></li>
<li><a href="#content" accesskey="c">Skip to Content (c)</a></li>
<li><a href="#footer" accesskey="f">Skip to Footer (f)</a></li>
</ul>
</nav>
<nav id="nav">
<ul>
<li class="sub"><a accesskey="1" href="./">Tosh-2 <span>(Switch Device)</span></a> <em>(1)</em>
<ul>
<li><a href="./">Toshendra</a></li>
<li class="active"><a href="./">Tosh-2</a></li>
<li class="a"><a href="./">Add Device</a></li>
</ul>
</li>
</ul>
<ul>
<li class="a"><a accesskey="2" href="./"><i class="icon-cog"></i> Settings</a> <em>(2)</em></li>
<li><a accesskey="3" href="./">Support</a> <em>(3)</em></li>
<li><a accesskey="4" href="./">Docs</a> <em>(4)</em></li>
<li><a accesskey="5" href="./"><i class="icon-globe"></i> Language</a> <em>(5)</em></li>
<li class="b"><a accesskey="6" href="./">TS</a> <em>(6)</em></li>
</ul>
</nav>
</header>
<nav id="aside">
<ul>
<li class="active"><a href="./"><i class="icon-bitcoin-circle"></i> <span>Bitcoin (BTC)</span></a></li>
<li><a href="./"><i class="icon-bitcoin-square"></i> <span>Bitcoin (BTC)</span></a></li>
<li><a href="./"><i class="icon-dash"></i> <span>Dash (DASH)</span></a></li>
<li><a href="./"><i class="icon-litecoin"></i> <span>Litecoin (LTC)</span></a></li>
<li><a href="./"><i class="icon-zcash"></i> <span>Zcash (ZEC)</span></a></li>
<li><a href="./"><i class="icon-ethereum"></i> <span>Ethereum (ETH)</span></a></li>
<li><a href="./"><i class="icon-ethereum-classic"></i> <span>Ethereum Classic (ETC)</span></a></li>
</ul>
</nav>
<form action="./" method="post" id="heading">
<h1>Bitcoin (BTC)</h1>
<ul>
<li><label for="aca"><input type="checkbox" id="aca" name="aca" checked> Account #1</label></li>
<li><label for="acb"><input type="checkbox" id="acb" name="acb"> Account #2</label></li>
<li><a href="./">Add account</a></li>
<li class="text-right"><a href="./">Legacy accounts <i class="icon-info"></i></a></li>
</ul>
</form>
<article id="content">
<input type="submit" value="Generate Key" onclick="generateWIFKey();"></input>
<p>Key: </p>
<p id="paraKey"></p></br>
<ul id="todos"></ul>
<p>Address: </p>
<p id="paraAddress"></p>
<input type="submit" value="Generate Random Mnemonic" onclick="generateMnemonic();"></input>
<p>Mnemonic: </p>
<p id="paraMnemonic"></p>
<p>HD Key: </p>
<p id="paraHDKey"></p>
<p>HD Master Address: </p>
<p id="paraHDAddress"></p>
<input type="submit" value="Generate Child Address" onclick="chidAddressFromHDKey();"></input>
<p>Child Addresses: </p>
<p id="paraChildAdd"></p>
<br/>
<input type="submit" value="Generate Change Address" onclick="changeAddressFromHDKey();"></input>
<p>Change Addresses: </p>
<p id="paraChangeAdd"></p>
<input type="submit" value="Get unspent output" onclick="getUTXO();"></input>
<p>Total Balance: </p>
<p id="paraTotalBalance"></p>
<p>Enter sending address: </p>
<input id="txtSendAddress" type="text" value=""></input>
<p>Enter amount: </p>
<input id="txtAmount" type="text"></input>
<p>Enter fees: </p>
<input id="txtFees" type="text"></input>
<br/>
<input type="submit" value="Send Transaction" onclick="sendTrans();"></input>
<p id="paraTransaction"></p><br/><br/>
<input type="submit" value="Generate Mnemonics with Pass" onclick="mnemonicsWithPass();"></input> <br/><br/>
<p></p>
<input type="submit" value="Get last address" onclick="last();"></input>
</article>
<footer id="footer">
<ul>
<li>Copyright Vault0x @<span class="date">2017</span></li>
<li><a href="./">Terms</a></li>
<li><a href="./">Privacy Policy</a></li>
</ul>
</footer>
</div>
<script src="javascript/jquery.js"></script>
<script src="javascript/scripts.js"></script>
<script src="javascript/custom.js"></script>
<script src="javascript/mobile.js"></script>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script src="javascript/bitcore-lib/bitcore-lib.min.js"></script>
<script src="javascript/bitcore-mnemonic/bitcore-mnemonic.min.js"></script>
<script src="javascript/bitcore-explorers/bitcore-explorers.min.js"></script>
<script src="javascript/app.js"></script>
<script type="text/javascript">
function generateWIFKey() {
var key = generateWIFPrivateKey("testnet");
var address = getAddressFromWIF(key);
$("#paraKey").text(key);
$("#paraAddress").text(address);
}
function generateMnemonic() {
var mnemonicString = generateRandomMnemonic();
var hdkey = genHDPrivKeyMnemonics(mnemonicString,'');
var mastAdd = getMasterAddressFromHDKey(hdkey, 'testnet');
$("#paraMnemonic").text(mnemonicString);
$("#paraHDKey").text(hdkey);
$("#paraHDAddress").text(mastAdd);
}
function chidAddressFromHDKey() {
var xpriv = $("#paraHDKey").text();
var childadd = genChildAddress(xpriv,'testnet');
$("#paraChildAdd").append('<br/>' + childadd);
}
function changeAddressFromHDKey() {
var xpriv = $("#paraHDKey").text();
var changeadd = genChangeAddress(xpriv,'testnet');
$("#paraChangeAdd").append('<br/>' + changeadd);
}
async function getUTXO() {
var add1 = 'miE3tcB1NSz5ZkGLK9s42iaMAkvCNmvawP';
var add2 = 'mvzyDSRpEkaHxpg45PNTXoPkZA6m5N7sou';
var add3 = 'mh2KzVRN5t9NprCpDdpvkvbNgMZ1DLobEM';
var add = [];
add.push(add1);
add.push(add2);
add.push(add3);
//var normalAdd = 'mrAVRTdpeRseU6F1R3kkApWKpxTAEg7ywQ';
//add.push(normalAdd);
try {
var result = await getBalancefromUtxosTestnet(add);
}
catch(err)
{
console.log(err);
}
console.log(result);
$("#paraTotalBalance").append(result);
}
var tx;
async function sendTrans() {
// var privatekey = 'xprv9s21ZrQH143K2sA8Fi1fGkP1wH36jJbBAUdVdWRK9ySAcRNXZ5P6JCRB4FKKZWRTbc5BAuNpmHbw9ken58TK6uv3x26jbauFQoCBdRY7WWA';
// var childkey1 = 'xprv9uoSGe19dhrjJBbuBmP4vjuFUprUQM32Us3o3hdKnnqYr6t4UxCk9TaDWFxnGdoQsQboMs2Yvuuzpbu73QCVU8vq54hsbdQJr1FUBgUM2iB';
// var childkey2 = 'xprv9uoSGe19dhrjMhrjpmNwCo6jWigWoUVqUfUrEoPr4YLfGQRJG2hQGnayYXe98i7bn6CouhaDJGT9L3nY61LTqKFtKEqidktadExNFydChWw';
// var childkey3 = 'xprv9uoSGe19dhrjNVfEG1GzN4wPTEdkZQserrzhnedSjMkuVLWyFaDqtnTEAnyEoMLFAbNnDCuxvCpR3PJ4M2r57j4nFkEancwNbbhrg66mXTK';
// var childkeys =[];
// childkeys.push(childkey1);
// childkeys.push(childkey2);
// childkeys.push(childkey3);
// var add1 = 'miE3tcB1NSz5ZkGLK9s42iaMAkvCNmvawP';
// var add2 = 'mvzyDSRpEkaHxpg45PNTXoPkZA6m5N7sou';
// var add3 = 'mh2KzVRN5t9NprCpDdpvkvbNgMZ1DLobEM';
var addresses1 = 'mz5zuqbCqJ27omvnhN2eH92RfXseCTCQ9o';
var addresses2 = 'myikb48svJrP9pUPYW7VVqxLRQGskU5jag';
var addresses3 = 'n37YHrgVXauo7X5jjMuBCiaPCf8AhCLhh6';
var addresses4 = 'mtoBfmDS7JMSxPRpXQYs1QJmHF3pxmY9zG';
var childkey1 = 'xprv9xDBkK3n4M3qrYuaw5byQeAYxyML4CWMF72SQPnLegNm2V2EAy4HkzsANitenW5WmbgdjXBtSoUtvcWHgvdiUY6FEd5FCKJpV9e3o3WCVVX';
var childkey2 = 'xprv9xDBkK3n4M3qsTkG4uMRC98m67o9DfkHhyGuuZVGdKTmHtcejWXyKrthG9hzNyNgwcRDHk55eHjBZFuXBpcWc1164AuDh1XcqGnNgYMfsvu';
var childkey3 = 'xprv9xDBkK3n4M3qvmmHx5UEYvb1cY8WeAdW1wNzDuAtQtr2nE3FG8GemLz2KqBqqmd64VsEr53uZsuw3RX4bnFDCUL7fMgC8uTepjZbWJH7pDX';
var childkey4 = 'xprv9xDBkK3n4M3qyyFzpPu7Zs5PS3vYCQjn2mHsGZoPfnKkBPGrgtexbUPJbXTsLW78feCSoYpKzg6oWMQtyr7R7w7uaCZTqVZsdPiqxfd412s';
var sendarray = [];
sendarray.push(addresses1);
sendarray.push(addresses2);
sendarray.push(addresses3);
sendarray.push(addresses4);
console.log("array", sendarray);
var childarray = [];
childarray.push(childkey1);
childarray.push(childkey2);
childarray.push(childkey3);
childarray.push(childkey4);
console.log("childarray", childarray);
var sendAddress = 'miMFq4xj1nKQ7Z8KDYZz6y5PkN23kJkrGw';//$("#txtSendAddress").val(); //n1YQfbZ7CTZz8m3xeekryaMBtdXNbhbJUj
var amount = 0.05;
var fees = 0.05;
// var add = [];
// add.push(add1);
// add.push(add2);
// add.push(add3);
//var normalAdd = 'mrAVRTdpeRseU6F1R3kkApWKpxTAEg7ywQ';
//add.push(normalAdd);
try {
txID = await sendTransactionfromUtxosTestnet(sendarray, sendAddress, amount, fees, childarray);
$("#paraTransaction").append(txID);
//console.log(tx);
}
catch(err)
{
console.log(err);
}
}
function mnemonicsWithPass() {
var mnemonicString = generateRandomMnemonic();
var password = "123456789";
var HDkey = genHDPrivKeyMnemonicsPass(mnemonicString, password, '');
// Check browser support and add values in localstorage
if (typeof(Storage) !== "undefined") {
// Store
localStorage.setItem("mnemonicString", mnemonicString); //store mnemonics string
localStorage.setItem("password", password); //sore password
localStorage.setItem("HDkey", HDkey); //HDkey
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
}
}
async function last() {
var xp = 'xprv9s21ZrQH143K2y3y8LTx37XF6eCucSqM9CxrbnQbCpNqB2ovmU3ZogviNGqgDCxccp5JX3krtkEtpDNU7ZtvpWG19WUUtuWQh4jqFTyEvWV';
var ect = 20;
var sct = 1;
//var lt = lastUsedAddress(xp, sct, ect);
var lastAddressUsed = await loopPromiseGetLastAddress(xp, sct, ect);
console.log("The last address used is :");
console.log(lastAddressUsed);
}
</script>
</body>
</html>