-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
473 lines (421 loc) · 11.9 KB
/
index.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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<!DOCTYPE html>
<html>
<head>
<title>XDN Paper Wallet Generator</title>
<script type="text/javascript" src="./numbers.js"></script>
<script type="text/javascript" src="./asm.js"></script>
<script type="text/javascript" src="./cnUtil.js"></script>
<script type="text/javascript" src="./qrcode.js"></script>
<script type="text/javascript" src="./html2canvas.js"></script>
<link href="./styles/bootstrap.min.css" rel="stylesheet">
<link href="./styles/bootstrap-theme.min.css" rel="stylesheet">
</head>
<body>
<style id="style" type="text/css">
body{
background: url('backgrounds/hero.png');
background-size: 100% auto;
}
.text-wallet{
width:842px !important;
display: inline-block;
}
.wallet{
border:1px solid #aaa;
height:595px !important;
display: inline-block;
background: url('backgrounds/graph.jpg');
background-size: 100% 100%;
margin-top: 25px;
}
.wallet .left{
border-right: 1px dashed #bbb;
height:595px !important;
}
.wallet .right{
border-left: 1px dashed #ccc;
height:595px !important;
}
.wallet .qrcode{
width: 250px !important;
height: 250px !important;
display: inline-block;
padding: 0px;
}
.wallet h4{
margin-top: 50px;
font-family: courier !important;
z-index: 100;
}
.wallet .base64{
word-break: break-all !important;
word-wrap: break-word !important;
margin:26px;
height: 105px;
}
.wallet .note .name{
margin-top: 12px;
color: #444;
font-weight: bold;
font-family: courier;
}
.wallet .note .desc{
margin-top: 12px;
color: #444;
font-family: courier;
padding:6px;
}
.wallet .qrcode img{
border: 1px solid #ccc;
display: inline;
margin-top: 20px;
}
.theform{
width: 50%;
min-width: 400px;
display: inline-block;
}
.theform small{
font-weight: bold;
font-family: courier !important;
}
#generate, .button{
width: 300px;
}
.navbar-inverse{
border-radius: 0px;
padding:6px;
color:#eee;
opacity: .6;
}
.move-left {
width: auto;
box-shadow: none;
}
.cb-fix {
width: 20px;
}
.error{
color: red;
font-weight: bold;
}
.wallet-full{
width:842px !important;
}
.wallet-public{
width: 421px !important;
}
#new_wallet {
margin-top: 5px;
}
</style>
<a href="https://github.com/skironDotNet/xdn-paperwallet" target="_blank" style="position: fixed; top:10px; right: 10px; z-index: 100;" class="btn btn-primary">
<i class="glyphicon glyphicon-heart-empty"></i> FORK
</a>
<div class="navbar navbar-inverse text-center">
<h1 class="text-center">
<img width="70" src="backgrounds/xdn.png">
</h1>
<small>
DIGITALNOTE PAPER AND BRAIN WALLET GENERATOR
</small>
</div>
<center>
<div class="theform form-horizontal" id="_form">
<h3>WALLET DESCRIPTION<br>
<small>
(optional)
</small>
</h3>
<input class="form-control input-lg" type="text" id="wallet-name" placeholder="organization / your name">
<small>Examples: "John Smith", "Funny Bears ltd.", "Sith Church"</small>
<hr>
<input class="form-control input-lg" type="text" id="wallet-desc" placeholder="wallet purpose">
<small>Examples: "Donate to the Sith Church.", "My DigitalNote account for savings"</small>
<hr>
<div class="row">
<div class="col-sm-12 move-left">
<input class="form-control checkbox-inline cb-fix" type="checkbox" id="cbBrain" />
<small>Create brain wallet</small>
</div>
</div>
<div id="pharses">
<input class="form-control input-lg" type="password" id="wallet-pharse" placeholder="passphrase">
<small>This must be a minimum 5 words (or 25 characters) to call it safe</small>
<input class="form-control input-lg" type="password" id="wallet-pharse-confirm" placeholder="confirm passphrase">
<small class="error" id="validationError"></small>
</div>
<hr>
<button id="generate" class="btn btn-lg btn-warning">
GENERATE RANDOM WALLET
</button>
<br>
<br>
</div>
</center>
<center id="_wallet">
<div class="text-wallet">
<div class="col-xs-6">
<h5>PRIVATE KEY</h5>
<textarea class="form-control" id='private_key'></textarea>
</div>
<div class="col-xs-6">
<h5>PAYMENT ADDRESS</h5>
<textarea class="form-control" id='public_address'></textarea>
</div>
<div class="col-xs-12">
<br>
<div class="col-xs-12" id="togglePrivate">
<input class="form-control checkbox-inline cb-fix" type="checkbox" id="cbShowPrivateQR" />
<small>Show private QR code</small>
</div>
<button class="btn btn-danger button" id="save_image">
SAVE AS IMAGE
</button>
<button class="btn btn-success button" id="print_image">
PRINT
</button>
<button class="btn btn-primary button" id="new_wallet">
GENERATE NEW WALLET
</button>
<br>
</div>
</div>
<div class="wallet wallet-full" id="wallet">
<div class="col-xs-6 left" id="wallet-private">
<h4>PRIVATE KEY</h4>
<div class="qrcode" id="private-key-qr">
</div>
<div class="base64" id="private-key">
dddZXiAthSgcc3sjTfkVB7N1jSgYv3dpVJF4Sx<br>
M1HNRRjo4AUDgheHYHMMGLnfLuQW7nGLtSrup<br>
SVXk7KUEgxPrQVJd3T87kvV6PrzieSP9CPkDy<br>
cKnzdGj99Wv8K1r8Wi5XTGEHn7Z5FsT24y8pq<br>
hiksjitbHnJ93JkibgxnkX2qr9x19xyA7LbK
</div>
<div class="note">
<p class="name">
WARNING!
</p>
<p class="desc">
Never show this piece to anyone! Never expose this QR code in public places!
</p>
</div>
</div>
<div class="col-xs-6 right" id="wallet-public">
<h4>PAYMENT ADDRESS</h4>
<div class="qrcode" id="public-address-qr">
</div>
<div class="base64" style="height: 55px;" id="public-address">
dddZXiAthSgcc3sjTfkVB7N1jSgYv3dpVJF4SxM1HNRRjo4AUDgheHYHMMGLnfLuQW7nGLtSrupSVXk7KUEgxPrQ2TGQUwLuD
</div>
<div class="note">
<p class="name" id="orgname">
DigitalNote Wallet
</p>
<p class="desc" id="purpose">
DigitalNote address for payments and messages.
</p>
</div>
</div>
</div>
</center>
<div class="well row" style="font-family: courier;">
<div class="col-sm-6 col-sm-offset-3">
<h4>ABOUT THE PAPER WALLET</h4>
<p>
<b>Paper Wallet Generator</b> is a tool that helps getting a DigitalNote(XDN) address. After generating a wallet you can start receiving payments without installing any software.
</p>
<p>
Paper Wallet consists of two parts: <u>Private Key</u> and <u>Payment Address</u>
</p>
<p>
<u>Payment Address</u> is your public account number. Share it with anyone to receive payments.
</p>
<p>
<u>Private Key</u> is what gives you administrative access to your money. Keep it somewhere safe. <br>
You can access your wallet by importing private key into the DigitalNote desktop application. ** Don't forget to backup current wallet before importing.
</p>
<br>
<h4>ABOUT THE BRAIN WALLET</h4>
<p>
By using passphrase you can recover your wallet in the future by using same passphrase, so no need to print qrcode.
</p>
<p class="error">
Warning: You should save the source to this page to make sure you can restore your wallet in the future. Chances are implementation of passphrase hashing algorithm may change overtime.
</p>
<br>
<h4>HOW TO USE</h4>
<ol>
<li>Press 'GENERATE WALLET' button.</li>
<li>Copy 'Private Key' and save it somewhere safe.</li>
<li>Save save paper wallet image to your disk</li>
<li>Print the paper wallet on actual paper</li>
<li>Cut the half with the private key</li>
<li>Make as many copies of the public address as you need</li>
<li>Share your public address when you want to receive payments/messages</li>
</ol>
</div>
</div>
<div id="result"></div>
<div class="well row" style="font-family: verdana;">
<div class="col-sm-6 col-sm-offset-3">
<p>© 2017 Anton A Nesterov (Original version)</p>
<p>© 2017 Pawel Cioch (Brain Wallet modification)</p>
</div>
</div>
</body>
<script type="text/javascript">
function el(id){return document.getElementById(id);}
var _form = el('_form'),
_wallet = el('_wallet'),
_cbBrain = el('cbBrain'),
_pharse = el('wallet-pharse'),
_pharseConfirm = el('wallet-pharse-confirm'),
_pharses = el('pharses'),
_generate = el('generate'),
_validationError = el('validationError'),
_cbShowPrivateQR = el('cbShowPrivateQR');
_wallet.style.display = 'none';
_pharses.style.display = 'none';
_cbBrain.checked = 0;
function break38(line){
//break line fix for html2canvas
var result = "";
for(var i=0; i<line.length; i++){
if(i!=0&&i%35==0){result += line[i]+"<br>";}
else{result += line[i];}
}
return result;
};
function generateWallet(pharse) {
var Config = {
coinUnitPlaces: 12,
coinSymbol: 'XDN',
coinName: 'DigitalNote',
coinUriPrefix: 'dnote:',
addressPrefix: 0xDB
};
var cnUtil = cnUtilGen(Config);
var seed = '';
var hex = cnBase58.bintohex(cnBase58.strtobin(pharse));
if (pharse) {
seed = cnUtil.sc_reduce32(cnUtil.cn_fast_hash(hex));
} else {
seed = cnUtil.sc_reduce32(cnUtil.rand_32());
}
var keys = cnUtil.create_address(seed);
var pub, priv;
pub = el('public_address').value = cnUtil.pubkeys_to_string(keys.spend.pub, keys.view.pub);
el('public-address').innerHTML = break38(pub);
var pub_qr = qrcode(12, 'L');
pub_qr.addData('dnote:'+pub);
pub_qr.make();
el('public-address-qr').innerHTML = pub_qr.createImgTag(3);
priv = el('private_key').value = cnUtil.encode_key(keys.spend.pub, keys.view.pub, keys.spend.sec, keys.view.sec);
el('private-key').innerHTML = break38(priv);
var priv_qr = qrcode(12, 'L');
priv_qr.addData(priv);
priv_qr.make();
el('private-key-qr').innerHTML = priv_qr.createImgTag(3);
if(!pharse)
{
showPrivateQR();
el('togglePrivate').style.display = 'none';
}
else{
_cbShowPrivateQR.checked = 0;
hidePrivateQR();
el('togglePrivate').style.display = 'block';
}
}
function hidePrivateQR()
{
el('wallet-private').style.display = 'none';
el('wallet-public').classList.replace('col-xs-6','col-xs-12');
el('wallet').className = 'wallet wallet-public';
}
function showPrivateQR()
{
el('wallet-private').style.display = 'block';
el('wallet-public').classList.replace('col-xs-12','col-xs-6');
el('wallet').className = 'wallet wallet-full';
}
function generate() {
if (_cbBrain.checked) {
if (!validatePharse()) {
return;
}
}
var pharse = _pharse.value;
clearPharse();
el('orgname').innerHTML = el('wallet-name').value || el('orgname').innerHTML;
el('purpose').innerHTML = el('wallet-desc').value || el('purpose').innerHTML;
generateWallet(pharse);
_form.style.display = 'none';
_wallet.style.display = 'block';
}
function validatePharse() {
_validationError.textContent = '';
if (_pharse.value.length < 25) {
_validationError.textContent = 'The passphrase too short!'
return false;
}
if (_pharse.value != _pharseConfirm.value) {
_validationError.textContent = 'The passphrase does not match the confirm passphrase!'
return false;
}
return true;
}
function clearPharse() {
_pharse.value = '';
_pharseConfirm.value = '';
}
function render(callback){
html2canvas(el('wallet'), {
onrendered: function(canvas) {
window.result_canvas = canvas;
if(callback) callback(canvas);
}
});
}
_cbBrain.onclick = function () {
if (_cbBrain.checked) {
_pharses.style.display = 'block';
_generate.textContent = 'GENERATE BRAIN WALLET';
_generate.classList.replace('btn-warning','btn-info');
}
else
{
_pharses.style.display = 'none';
_generate.textContent = 'GENERATE RANDOM WALLET';
_generate.classList.replace('btn-info','btn-warning');
}
}
_generate.onclick = generate;
_cbShowPrivateQR.onclick = function () {
if (_cbShowPrivateQR.checked) {
showPrivateQR();
}
else {
hidePrivateQR();
}
}
el('save_image').onclick = function(){
render(function(canvas){
var dataURL = canvas.toDataURL( "image/png" ).replace("image/png", "image/octet-stream");
window.location.href=dataURL;
});
}
el('print_image').onclick = function(){
render(function(canvas){
var dataURL = canvas.toDataURL( "image/png" );
window.open(dataURL, '_blank');
});
}
el('new_wallet').onclick = function(){
_form.style.display = 'block';
_wallet.style.display = 'none';
}
</script>
</html>