-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathdigibyte.html
More file actions
91 lines (86 loc) · 3.67 KB
/
Copy pathdigibyte.html
File metadata and controls
91 lines (86 loc) · 3.67 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DigiByte Cold Wallet Generator</title>
<meta name="description" content="A lightweight, client-side, reliable, fast, open-source universal cold wallet generator supporting almost every major cryptocurrency">
<meta name="keywords" content="minimal, reliable, fast, universal, cold, wallet, generator, offline, digibyte, dgb, cryptocurrency">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style2.css">
<script src="js/bitcoinjs-lib.js"></script>
<script src="js/bip39.min.js"></script>
<script src="js/qrcode.js"></script>
</head>
<body onload="generate()">
<div class="container">
<h1>DigiByte Cold Wallet</h1>
<div class="button-group">
<button onclick="window.location.href='index.html'">Home</button>
<button onclick="generate()">Generate</button>
<button onclick="window.print()">Print</button>
</div>
<div class="info-box">
<label>Public Address (SHARE)</label>
<span id="public">Click Generate to create wallet</span>
<div id="public_qr" class="qr-code"></div>
</div>
<div class="info-box">
<label>Mnemonic Seed (SECRET)</label>
<span id="secret">Click Generate to create wallet</span>
<div id="secret_qr" class="qr-code"></div>
</div>
</div>
<script>
async function generate() {
if (typeof bip39 === "undefined" || typeof bitcoin === "undefined") {
alert("bip39 and bitcoinjs-lib are required!");
return;
}
// DigiByte network params
const digibyte = {
messagePrefix: '\x19Digibyte Signed Message:\n',
bech32: 'dgb',
bip32: {
public: 0x0488B21E,
private: 0x0488ADE4,
},
pubKeyHash: 0x1e,
scriptHash: 0x3f,
wif: 0x80,
};
const mnemonic = bip39.generateMnemonic(256);
const seed = bip39.mnemonicToSeedSync(mnemonic);
// BIP44 coin type for Digibyte is 20 (m/44'/20'/0'/0/0)
const root = bitcoin.bip32.fromSeed(seed, digibyte);
const child = root.derivePath("m/44'/20'/0'/0/0");
const { address } = bitcoin.payments.p2wpkh({ pubkey: child.publicKey, network: digibyte });
const publicElem = document.getElementById("public");
const mnemonicElem = document.getElementById("secret");
const publicQRElem = document.getElementById("public_qr");
const mnemonicQRElem = document.getElementById("secret_qr");
if (publicElem && mnemonicElem && publicQRElem && mnemonicQRElem) {
publicElem.textContent = address;
mnemonicElem.textContent = mnemonic;
publicQRElem.innerHTML = "";
mnemonicQRElem.innerHTML = "";
new QRCode(publicQRElem, {
text: address,
width: 100,
height: 100,
colorDark: "#e0e0e0",
colorLight: "#1e1e1e",
correctLevel: QRCode.CorrectLevel.H
});
new QRCode(mnemonicQRElem, {
text: mnemonic,
width: 100,
height: 100,
colorDark: "#e0e0e0",
colorLight: "#1e1e1e",
correctLevel: QRCode.CorrectLevel.H
});
}
}
</script>
</body>
</html>