forked from litecoin-project/p2sh-convert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
66 lines (53 loc) · 1.65 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
<html>
<head>
<title>P2SH Converter</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</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 = 55;
break;
case 55:
message = "Mainnet p2sh address (deprecated): ";
version = 5;
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="#">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"/>
</div>
</html>