-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
161 lines (126 loc) · 8.46 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Load CSS. -->
<!-- Load JavaScript library. -->
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
<!-- Load Bootstrap. -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<!-- Load BitcoinJS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bitcoinjs-lib/0.2.0-1/bitcoinjs-min.js" integrity="sha256-FilB5ir32toR4c80H4e31Wzh7MbA0kOd/LzvRxgletA=" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/jquery.qrcode.min.js"></script>
<script type="text/javascript" src="js/bitcore-lib.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<title>Bitcoin Script Online Debugger</title>
</head>
<body>
<div class="modal fade" id="modal-qr" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">QR code</h4>
</div>
<div class="modal-body">
<div class="text-center">
<div id="qr-image"></div>
<p id="qr-text"></p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="container">
<div class="page-header">
<h1>Bitcoin Script Online Debugger</h1>
</div>
<p><a href="javascript:$('#usage').toggle('fast');">≫ Toggle Usage</a></p>
<div id="usage" style="display:none;">
<p>Enter a script to debug in the following textarea. The script is automatically parsed and executed. The step-by-step execution status (incl. stack status) will be shown.</p>
<p>Notice that there are some restriction (some of them are inherited from the backend library, Bitcore):</p>
<ul>
<li>Hex data should be prefixed by "0x".</li>
<li>Hex data to be pushed onto the stack should be prefixed by the number of bytes to be pushed (e.g. "4 0x01020304") or OP_PUSHDATA? should be used (e.g. "OP_PUSHDATA1 4 0x01020304").</li>
<li>Signature checks such as OP_CHECKSIG and OP_CHECKMULTISIG are not supported (yet).</li>
</ul>
<p>Users not being familiar with Bitcoin's script language should refer to <a href="https://en.bitcoin.it/wiki/Script">this article</a> at Bitcoin Wiki.</p>
<p>Tha sample code shown by default is "transaction puzzle" described at <a href="https://en.bitcoin.it/wiki/Script#Transaction_puzzle">Bitcoin Wiki</a>. The first 80byte pushdata is the hex-encoded block header of the genesis block and the second to last push data is the doulbe-SHA256 hash of it, namely the block hash (reversed block ID) of the genesis block.</p>
<p>The input code can be specified by <a href="?input=OP_1%20OP_DUP%20OP_ADD%20OP_DUP%20OP_ADD%20OP_DUP%20OP_ADD%20OP_DUP%20OP_ADD%20OP_16%20OP_EQUAL">URL query</a>. Use "input" as a key.</p>
<p>Enjoy scripting!</p>
</div>
<h2>Input</h2>
<textarea id="input" rows="10" class="form-control" title="Enter your script here. It will be executed and evaluated automatically." style="width:100%;" onkeydown="rerun();" onkeyup="rerun();" onchange="rerun();"></textarea>
<div class="text-center" style="margin-top:10px;">
<div class="btn-group" id="template-selector"></div>
</div>
<div class="text-center" style="margin-top:30px;font-size:300%;"><span class="glyphicon glyphicon-chevron-down"></span></div>
<h2>Results</h2>
<div id="result-error" style="color:red;"></div>
<div class="text-center" style="font-size:200%;margin-bottom:30px;">
<span id="result" class="label label-default">Result: ??</span>
</div>
<h3>Link to This Script</h3>
<input type="text" class="form-control" id="result-url" title="You can restart scripting by bookmarking this, or tell friends your beautiful script via this URL!" readonly="readonly" style="width:100%;" />
<h3>Human-readable Text</h3>
<div id="result-text-error" style="color:red;">Failed to parse input script. Please check the syntax.</div>
<textarea id="result-text" class="form-control" title="Formatted script." rows="3" style="width:100%;" readonly="readonly"></textarea>
<h3>Hex</h3>
<textarea id="result-hex" class="form-control" title="Binary-encoded (assembled) script." rows="3" style="width:100%;" readonly="readonly"></textarea>
<h3>P2SH Address</h3>
<div class="row">
<div class="col-md-6">
<div class="input-group" title="Pay-to-Script-Hash (P2SH) address of your script (mainnet). You can fund your coins to this address to test your script on the real network.">
<span class="input-group-addon">Mainnet <span style="color:white;background-color:#ff9900;border-radius:50%;padding:2px 5px 3px 5px;"><span class="glyphicon glyphicon-btc" style="font-size:80%;"></span></span></span>
<input type="text" class="form-control" id="result-address-mainnet" readonly="readonly" style="width:100%;" />
<span class="input-group-addon">
<a href="" id="result-address-mainnet-explorer"><span class="glyphicon glyphicon-search"></span></a>
<a href="javascript:showqr('mainnet');" style="color:black;"><span class="glyphicon glyphicon-qrcode"></span></a>
</span>
</div>
</div>
<div class="col-md-6">
<div class="input-group" title="Pay-to-Script-Hash (P2SH) address of your script (testnet). You can fund your coins to this address to test your script on the real network.">
<span class="input-group-addon">Testnet <span style="color:white;background-color:#66f826;border-radius:50%;padding:2px 5px 3px 5px;"><span class="glyphicon glyphicon-btc" style="font-size:80%;"></span></span></span>
<input type="text" class="form-control" id="result-address-testnet" readonly="readonly" style="width:100%;" />
<span class="input-group-addon">
<a href="" id="result-address-testnet-explorer"><span class="glyphicon glyphicon-search"></span></a>
<a href="javascript:showqr('testnet');" style="color:black;"><span class="glyphicon glyphicon-qrcode"></span></a>
</span>
</div>
</div>
</div>
<div class="text-center" style="margin:10px 0px;">
<p>Wanna redeem your deposits? Try <a href="https://bip32jp.github.io/english/createp2sh.html">here</a>! (thx <a href="https://twitter.com/kinoshitajona">@kinoshitajona</a>!)</p>
</div>
<h3>Step Execution</h3>
<table id="result-steps" class="table table-bordered">
<thead>
<tr>
<th style="width:50px;" title="The # of steps executed (program counter).">#Step</th>
<th title="The stack status after a step execution.">Resulted Stack</th>
<th title="An OP code executed at this step.">Executed OP Code</th>
<th title="OP codes wainting for execution.">Remaining OP Codes</th>
</tr>
</thead>
<tbody></tbody>
</table>
<hr />
<footer>
<div class="pull-left">
<p>Copyright <a href="https://twitter.com/visvirial">@visvirial</a> 2016. All rights are reserved.</p>
</div>
<div class="pull-right">
<p>[ Powered by <a href="https://bitcore.io/">Bitcore</a> | <a href="https://github.com/visvirial/bitcoin-script-debugger">Source Repo (GitHub)</a> | Hosted at <a href="https://pages.github.com/">GitHub Pages</a> | <a href="https://github.com/visvirial/bitcoin-script-debugger/archive/master.zip" title="This service is serverless and can be run locally in case of internet connection trouble!">Download ZIP</a> ]</p>
</div>
</footer>
</div>
</body>
</html>