-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
59 lines (54 loc) · 2.2 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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<title>Kaspa Payload to Address</title>
</head>
<body>
<h2>Kaspa Payload to Address</h2>
<div>
<p>
This small page can parse <em>some</em> payloads of coinbase transactions of kaspad. This is not a full implementation of kaspad script reader.
</p>
</div>
<input type="text" class="form-control" id="payload" aria-describedby="payload" placeholder="Enter Payload or Block Hash">
<input class="form-control" type="text" id="output-address" placeholder="Address" readonly>
<input class="form-control" type="text" id="output-miner" placeholder="Miner" readonly>
<script src="./bech32.js"></script>
<script src="./block.js"></script>
<script>
const clear = () => {
const outputAddress = document.querySelector("#output-address");
const outputMiner = document.querySelector("#output-miner");
outputAddress.value = "";
outputMiner.value = "";
}
const displayPayload = (payload) => {
const [address, miner] = parsePayload(payload);
const outputAddress = document.querySelector("#output-address");
const outputMiner = document.querySelector("#output-miner");
if (address === payload && payload !== "") {
outputAddress.value = "Failed parsing payload";
outputMiner.value = "";
}
else {
outputAddress.value = address;
outputMiner.value = miner;
}
}
const payload = document.querySelector('#payload');
payload.addEventListener("change", event => {
clear();
// Probably a block hash
if (event.target.value.length == 64) {
getCoinbase(event.target.value).then(displayPayload);
} else if (event.target.value.length > 64) {
displayPayload(event.target.value);
} else {
document.querySelector("#output-address").value = "Failed parsing payload";
}
});
</script>
</body>
</html>