forked from octra-labs/wallet-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
630 lines (547 loc) · 20.8 KB
/
index.html
File metadata and controls
630 lines (547 loc) · 20.8 KB
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
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="/assets/logo.svg" />
<title>Octra Wallet Generator</title>
<style>
@font-face {
font-family: 'National';
src: url('/assets/national-regular.woff2') format('woff2');
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'FoundersGrotesk';
src: url('/assets/founders-grotesk-bold.woff2') format('woff2');
font-weight: 700;
font-style: normal;
font-display: swap;
}
:root {
/* Colors from Figma design system */
--blue-50-base: #0000db;
--blue-40: #043aff;
--blue-30: #6196ff;
--blue-20: #b1c8fb;
--blue-10: #ecf2ff;
--blue-60: #0808a0;
--blue-70: #06066f;
--blue-80: #040525;
--gray-0: #ffffff;
--gray-10: #f1f1f1;
--gray-20: #eaeaea;
--gray-30: #dedede;
--gray-40: #9b9b9b;
--gray-50: #696969;
--gray-60: #313131;
--gray-70: #222222;
--gray-80: #181818;
--orange-10: #ffeec2;
--orange-20: #fcb73e;
--orange-30: #ef8b17;
--orange-40: #d97400;
--orange-80: #432f18;
--text-main: #222222;
--button-primary-text: #ffffff;
--template-background: #ffffff;
--border-disabled: #dedede;
--border-color-500: #15151566;
/* Legacy variables for compatibility */
--background-default-color: #181818;
--background-primary-color: var(--blue-50-base);
--text-primary-color: var(--button-primary-text);
--text-inverted-color: var(--button-primary-text);
--border-color: var(--gray-40);
}
body {
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
print-color-adjust: exact;
font-family: 'National', Tahoma, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-size: 18px;
line-height: 26px;
font-weight: 400;
margin: 0;
padding: 0;
background-color: var(--background-default-color);
color: var(--text-inverted-color);
}
.container {
max-width: 1024px;
width: 100%;
padding: 20px;
}
h1 {
text-align: center;
font-family: 'FoundersGrotesk', 'National', sans-serif;
font-size: 62px;
line-height: 64px;
font-weight: 700;
margin-bottom: 40px;
letter-spacing: -0.02em;
}
h3 {
font-family: 'FoundersGrotesk', 'National', sans-serif;
font-size: 36px;
line-height: 42px;
font-weight: 700;
margin-bottom: 16px;
}
h5 {
font-family: 'National', sans-serif;
font-size: 18px;
line-height: 22px;
font-weight: 700;
}
.button {
outline: 1px solid var(--blue-50-base);
background: var(--blue-50-base);
color: var(--button-primary-text);
border: none;
padding: 8px 16px;
text-align: center;
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
font-family: 'National', sans-serif;
font-size: 18px;
line-height: 26px;
font-weight: 400;
margin: 4px 2px;
cursor: pointer;
border-radius: 0;
transition: background-color 0.2s, border-color 0.2s;
min-height: 42px;
}
.button:hover {
background: var(--blue-40);
outline-color: var(--blue-40);
}
.button:disabled {
background-color: var(--gray-10);
outline: none;
color: var(--gray-40);
cursor: not-allowed;
}
.button.secondary {
background: var(--gray-0);
color: var(--text-main);
outline-color: var(--gray-40);
}
.button.secondary:hover {
background: var(--gray-10);
outline-color: var(--gray-40);
}
.button.secondary:disabled {
background: var(--gray-10);
color: var(--gray-40);
outline-color: var(--border-disabled);
}
.button.borderless {
background: var(--gray-0);
color: var(--text-main);
outline: none;
}
.button.borderless:hover {
background: var(--gray-10);
}
.button.borderless:disabled {
background: var(--gray-10);
color: var(--gray-40);
}
.button.size-large {
padding: 10px 16px;
font-size: 20px;
line-height: 30px;
min-height: 50px;
}
.button.size-xl {
padding: 12px 16px;
font-size: 24px;
line-height: 32px;
min-height: 56px;
}
.button.selected {
outline: 3px solid var(--blue-40);
outline-offset: -1.5px;
}
.button.selected.primary {
outline: 2px solid var(--blue-40);
outline-offset: -2px;
border: 1px solid var(--gray-0);
}
.button.fullwidth {
width: 100%;
}
.status {
margin: 40px 0 16px;
padding: 20px;
background-color: rgba(255, 255, 255, 0.05);
border: 1px solid var(--border-color);
min-height: 104px;
white-space: pre-wrap;
overflow-y: auto;
max-height: 400px;
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
font-size: 14px;
line-height: 18px;
font-weight: 400;
}
.wallet-info {
background-color: transparent;
padding: 20px 0;
margin-top: 20px;
display: none;
}
.wallet-field {
margin: 20px 0;
display: flex;
flex-direction: row;
box-sizing: border-box;
gap: 24px;
}
.field-label {
font-family: 'National', sans-serif;
font-size: 16px;
line-height: 20px;
font-weight: 400;
flex-basis: 200px;
}
.field-value {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
font-size: 14px;
line-height: 18px;
font-weight: 400;
word-break: break-all;
width: 100%;
}
.field-value.inputs {
margin-top: -12px;
}
.warning {
background-color: var(--gray-60);
color: var(--text-inverted-color);
padding: 12px 16px 12px 36px;
margin: 20px 0;
font-family: 'National', sans-serif;
position: relative;
font-size: 16px;
line-height: 20px;
}
.warning::before {
content: '';
position: absolute;
background: url('assets/icon-warning.svg') 0 0 no-repeat;
width: 16px;
height: 16px;
left: 12px;
top: 14px;
}
.address-info {
font-size: 12px;
color: #666;
margin-top: 5px;
}
select, input[type="number"] {
background: var(--background-default-color);
color: var(--text-inverted-color);
border: 1px solid var(--gray-40);
padding: 8px 12px;
border-radius: 0;
font-family: 'National', sans-serif;
font-size: 16px;
line-height: 22px;
font-weight: 500;
}
select:focus, input[type="number"]:focus {
outline: 2px solid var(--blue-40);
outline-offset: -2px;
border-color: var(--blue-40);
}
select:disabled, input[type="number"]:disabled {
background: var(--gray-10);
color: var(--gray-40);
border-color: var(--border-disabled);
cursor: not-allowed;
}
.derive-button {
padding: 6px 12px;
font-size: 16px;
line-height: 24px;
margin-left: 4px;
min-height: 36px;
}
/* Typography classes from Figma design system */
.text-h1 {
font-family: 'FoundersGrotesk', sans-serif;
font-size: 62px;
line-height: 64px;
font-weight: 700;
}
.text-h3 {
font-family: 'FoundersGrotesk', sans-serif;
font-size: 36px;
line-height: 42px;
font-weight: 700;
}
.text-h5 {
font-family: 'National', sans-serif;
font-size: 18px;
line-height: 22px;
font-weight: 700;
}
.text-huge {
font-family: 'National', sans-serif;
font-size: 24px;
line-height: 32px;
font-weight: 400;
}
.text-large {
font-family: 'National', sans-serif;
font-size: 20px;
line-height: 30px;
font-weight: 400;
}
.text-normal {
font-family: 'National', sans-serif;
font-size: 18px;
line-height: 26px;
font-weight: 400;
}
.text-small {
font-family: 'National', sans-serif;
font-size: 16px;
line-height: 22px;
font-weight: 500;
}
.text-extra-small {
font-family: 'National', sans-serif;
font-size: 14px;
line-height: 20px;
font-weight: 400;
}
.text-mono {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
font-size: 14px;
line-height: 18px;
font-weight: 400;
}
#derivedAddress {
margin-top: 15px;
padding: 10px;
background-color: var(--gray-60);
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<h1>octra wallet generation</h1>
<div class="main">
<div>
<div class="status" id="status">Ready to generate wallet...</div>
<div style="text-align: center;">
<button id="generateBtn" class="button size-large fullwidth" onclick="generateWallet()">generate new wallet</button>
</div>
</div>
<div class="wallet-info" id="walletInfo">
<h3>your wallet</h3>
<div class="warning">
do not store this file online or on cloud services, keep your private key secure and never share it!
</div>
<div class="wallet-field">
<div class="field-label">mnemonic (12 words)</div>
<div class="field-value" id="mnemonic"></div>
</div>
<div class="wallet-field">
<div class="field-label">private key</div>
<div class="field-value">
Raw: <span id="privateKeyRaw"></span><br>
B64: <span id="privateKeyB64"></span>
</div>
</div>
<div class="wallet-field">
<div class="field-label">public key</div>
<div class="field-value">
Raw: <span id="publicKeyRaw"></span><br>
B64: <span id="publicKeyB64"></span>
</div>
</div>
<div class="wallet-field">
<div class="field-label">octra addres</div>
<div class="field-value" id="address"></div>
</div>
<div class="wallet-field">
<div class="field-label">technical information</div>
<div class="field-value">
Entropy: <span id="entropy"></span><br>
Seed: <span id="seed"></span><br>
Master Chain: <span id="masterChain"></span>
</div>
</div>
<div class="wallet-field">
<div class="field-label">signature test</div>
<div class="field-value">
Message: <span id="testMessage"></span><br>
Signature: <span id="testSignature"></span><br>
Validation: <span id="signatureValid"></span>
</div>
</div>
<div class="wallet-field">
<div class="field-label">HD derivation</div>
<div class="field-value inputs">
<label>Network Type:
<select id="networkType">
<option value="0">MainCoin</option>
<option value="1">SubCoin</option>
<option value="2">Contract</option>
<option value="3">Subnet</option>
<option value="4">Account</option>
</select>
</label>
<label style="margin-left: 10px;">Index:
<input type="number" id="derivationIndex" value="0" min="0" max="100" style="width: 60px;">
</label>
<button class="button derive-button" onclick="derivePath()">derive</button>
<div id="derivedAddress" style="display: none;">
Derived Address: <span id="derivedAddressValue"></span><br>
Path: <span id="derivedPath"></span>
</div>
</div>
</div>
<div class="wallet-field" id="saveInfo" style="display: none;">
<div class="field-label">file saved</div>
<div class="field-value">
Filename: <span id="savedFilename"></span><br>
Location: In the same directory as this script
</div>
</div>
</div>
</div>
</div>
<script>
let currentWallet = null;
function updateStatus(message) {
const status = document.getElementById('status');
status.textContent += message + '\n';
status.scrollTop = status.scrollHeight;
}
async function derivePath() {
if (!currentWallet) {
alert('Please generate a wallet first');
return;
}
const networkType = parseInt(document.getElementById('networkType').value);
const index = parseInt(document.getElementById('derivationIndex').value);
try {
const response = await fetch('/derive', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
seed_hex: currentWallet.seed_hex,
network_type: networkType,
index: index
})
});
const result = await response.json();
if (result.success) {
document.getElementById('derivedAddressValue').textContent = result.address;
document.getElementById('derivedPath').textContent = result.path;
document.getElementById('derivedAddress').style.display = 'block';
} else {
alert('Derivation failed: ' + result.error);
}
} catch (error) {
alert('Error: ' + error.message);
}
}
async function generateWallet() {
const btn = document.getElementById('generateBtn');
const status = document.getElementById('status');
const walletInfo = document.getElementById('walletInfo');
btn.disabled = true;
status.textContent = '';
walletInfo.style.display = 'none';
updateStatus('Starting wallet generation...');
try {
const response = await fetch('/generate', {
method: 'POST'
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
const lines = chunk.split('\n');
for (const line of lines) {
if (line.startsWith('data: ')) {
const data = JSON.parse(line.substring(6));
if (data.status) {
updateStatus(data.status);
}
if (data.wallet) {
currentWallet = data.wallet;
displayWallet(data.wallet);
}
}
}
}
} catch (error) {
updateStatus('ERROR: ' + error.message);
} finally {
btn.disabled = false;
}
}
function displayWallet(wallet) {
document.getElementById('mnemonic').textContent = wallet.mnemonic.join(' ');
document.getElementById('privateKeyRaw').textContent = wallet.private_key_hex;
document.getElementById('privateKeyB64').textContent = wallet.private_key_b64;
document.getElementById('publicKeyRaw').textContent = wallet.public_key_hex;
document.getElementById('publicKeyB64').textContent = wallet.public_key_b64;
document.getElementById('address').textContent = wallet.address;
document.getElementById('entropy').textContent = wallet.entropy_hex;
document.getElementById('seed').textContent = wallet.seed_hex.substring(0, 64) + '...';
document.getElementById('masterChain').textContent = wallet.master_chain_hex;
document.getElementById('testMessage').textContent = wallet.test_message;
document.getElementById('testSignature').textContent = wallet.test_signature;
document.getElementById('signatureValid').textContent = wallet.signature_valid ? 'VALID' : 'INVALID';
document.getElementById('walletInfo').style.display = 'block';
// Auto-save wallet
saveWallet();
}
async function saveWallet() {
if (!currentWallet) return;
try {
const response = await fetch('/save', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(currentWallet)
});
if (response.ok) {
const result = await response.json();
updateStatus('Wallet saved to: ' + result.filename);
document.getElementById('savedFilename').textContent = result.filename;
document.getElementById('saveInfo').style.display = 'flex';
} else {
updateStatus('ERROR: Failed to save wallet');
}
} catch (error) {
updateStatus('ERROR: ' + error.message);
}
}
</script>
</body>
</html>