-
Notifications
You must be signed in to change notification settings - Fork 54
/
index.html
76 lines (63 loc) · 1.96 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
<html>
<head>
<title>Litecoin P2SH Converter</title>
<link rel="stylesheet" href="bootstrap_v3.3.7.min.css">
<link rel="shortcut icon" type="image/png" href="litecoin.png">
</head>
<script src='bitcoinjs.min.js'></script>
<script type="text/javascript">
function convert() {
try {
address = document.getElementById('address').value;
decoded = bitcoin.address.fromBase58Check(address);
version = decoded['version']
switch (version) {
case 5:
message = "Mainnet p2sh address: ";
version = 50;
break;
case 50:
message = "Mainnet p2sh address (deprecated): ";
version = 5;
break;
case 196:
message = "Testnet p2sh address: ";
version = 58;
break;
case 58:
message = "Testnet p2sh address (deprecated): ";
version = 196;
break;
default:
throw "unknown";
}
// 5 <-> 50
// 196 <-> 58
address = bitcoin.address.toBase58Check(decoded['hash'], version);
} catch(err) {
message = "Please enter a valid address."
address = "";
}
document.getElementById('message').innerText = message + address;
}
</script>
<div class="container">
<nav class="navbar navbar-default">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="#">Litecoin P2SH Converter</a>
</div>
</nav>
<div class="form-group row">
<div class="col-md-4">
<label for="address">P2SH Value:</label>
<input class="form-control" id="address" size="40" value=""/>
</div>
<div class="col-md-12">
<button class="btn btn-primary" type="button" onclick="convert();" style="margin-top: 4px">Convert</button>
</div>
</div>
<label id="message"/>
<footer style="margin-top: 7em;">This tool is <a href="https://github.com/litecoin-project/p2sh-convert">Open Source</a>. It can be downloaded and run offline for added security.</footer>
</div>
</html>