forked from LedgerHQ/btg-convert
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
78 lines (66 loc) · 2.15 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
77
78
<html>
<head>
<title>BTX P2SH / P2PKH - 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 0:
message = "BTX p2pkh address: ";
version = 3;
break;
case 3:
message = "BTC p2pkh address: ";
version = 0;
break;
case 5:
message = "BTX p2sh address: ";
version = 125;
break;
case 125:
message = "BTC p2sh address: ";
version = 5;
break;
default:
throw "unknown";
}
address = bitcoin.address.toBase58Check(decoded['hash'], version);
} catch(err) {
message = "Please enter a valid address."
address = "";
}
document.getElementById('message').innerText = message + address;
if ( address != "") {
document.getElementById('qr').src='https://chart.apis.google.com/chart?chs=150x150&cht=qr&chld=L&chl=' + 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="#">BTC to BTX Converter - for more Infos about BTX - visit our Webpage</a><a class="navbar-brand" href="https://bitcore.cc" target="_blank">https://bitcore.cc</a>
</div>
</nav>
<div class="form-group row">
<div class="col-md-4">
<label for="address">Address:</label>
<input class="form-control" id="address" size="40" value=""/>
</div>
<div class="col-md-4">
<img src="btx.png">
</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"></label><br/>
<img id="qr">
</div>
</html>