-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathlitecoin.html
More file actions
97 lines (89 loc) · 3.81 KB
/
Copy pathlitecoin.html
File metadata and controls
97 lines (89 loc) · 3.81 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
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=UTF-8>
<title>Litecoin 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, litecoin, ltc, 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/qrcode.js"></script>
<script src="js/bip39.min.js"></script>
</head>
<body onload=generate()>
<div class="container">
<h1>Litecoin 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;
}
// Litecoin network params
const litecoin = {
messagePrefix: '\x19Litecoin Signed Message:\n',
bech32: 'ltc',
bip32: {
public: 0x019da462,
private: 0x019d9cfe
},
pubKeyHash: 0x30,
scriptHash: 0x32,
wif: 0xb0
};
// 1. Generate mnemonic
const mnemonic = bip39.generateMnemonic(256); // 24-word phrase
// 2. Get seed from mnemonic
const seed = bip39.mnemonicToSeedSync(mnemonic); // Buffer
// 3. Derive Litecoin key from seed (BIP84 for segwit/bech32)
const root = bitcoin.bip32.fromSeed(seed, litecoin);
const child = root.derivePath("m/84'/2'/0'/0/0"); // BIP84 for Litecoin
const { address } = bitcoin.payments.p2wpkh({ pubkey: child.publicKey, network: litecoin });
// Update DOM
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>