-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathecash.html
More file actions
66 lines (66 loc) · 2.72 KB
/
Copy pathecash.html
File metadata and controls
66 lines (66 loc) · 2.72 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>eCash 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="ecash, xec, cold, wallet, generator, bip39, bip44, mnemonic">
<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>eCash 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>
function generate() {
if (typeof bip39 === "undefined" || typeof bitcoin === "undefined") {
alert("bip39 and bitcoinjs-lib are required!");
return;
}
const ecash = {
messagePrefix: '\x19eCash Signed Message:\n',
bech32: '',
bip32: { public: 0x0488B21E, private: 0x0488ADE4 },
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80
};
// BIP44 coin type for eCash is 899
const mnemonic = bip39.generateMnemonic(256);
const seed = bip39.mnemonicToSeedSync(mnemonic);
const root = bitcoin.bip32.fromSeed(seed, ecash);
const child = root.derivePath("m/44'/899'/0'/0/0");
const { address } = bitcoin.payments.p2pkh({ pubkey: child.publicKey, network: ecash });
document.getElementById("public").textContent = address;
document.getElementById("secret").textContent = mnemonic;
document.getElementById("public_qr").innerHTML = "";
document.getElementById("secret_qr").innerHTML = "";
new QRCode(document.getElementById("public_qr"), {
text: address, width: 100, height: 100, colorDark: "#e0e0e0", colorLight: "#1e1e1e", correctLevel: QRCode.CorrectLevel.H
});
new QRCode(document.getElementById("secret_qr"), {
text: mnemonic, width: 100, height: 100, colorDark: "#e0e0e0", colorLight: "#1e1e1e", correctLevel: QRCode.CorrectLevel.H
});
}
</script>
</body>
</html>