|
18 | 18 | <meta name="keyword" content="Bootstrap,Admin,Template,Open,Source,jQuery,CSS,HTML,RWD,Dashboard">
|
19 | 19 | <title>Full Cycle - Bitcoin Visualizer</title>
|
20 | 20 | <!-- Icons-->
|
21 |
| - <link href="node_modules/@coreui/icons/css/coreui-icons.min.css" rel="stylesheet"> |
22 |
| - <link href="node_modules/flag-icon-css/css/flag-icon.min.css" rel="stylesheet"> |
| 21 | + <link href="dist/coreui-icons.min.css" rel="stylesheet"> |
| 22 | + <link href="dist/flag-icon.min.css" rel="stylesheet"> |
23 | 23 | <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
24 |
| - <link href="node_modules/simple-line-icons/css/simple-line-icons.css" rel="stylesheet"> |
| 24 | + <!-- <link href="node_modules/simple-line-icons/css/simple-line-icons.css" rel="stylesheet"> --> |
25 | 25 | <!-- Main styles for this application-->
|
26 | 26 | <link href="css/style.css" rel="stylesheet">
|
27 | 27 | <link href="vendors/pace-progress/css/pace.min.css" rel="stylesheet">
|
|
123 | 123 | <div class="card">
|
124 | 124 | <div class="card-header">Script Visualizer</div>
|
125 | 125 | <div class="card-body">
|
126 |
| - <!-- /.row--> |
127 | 126 |
|
128 | 127 | <div class="card">
|
129 | 128 | <div class="card-header"><i class="fa fa-file-download fa-lg mt-4"></i>Load Transaction</div>
|
130 | 129 | <div class="card-body">
|
131 |
| - <input type="text" id="txtTxid" class="col-md-8" |
132 |
| - placeholder="Enter TxId" |
133 |
| - ></input> |
134 |
| - <button id="btnLoadTx">Load Tx</button> |
| 130 | + <div class="row pb-3"> |
| 131 | + <input type="text" id="txtTxid" class="col-md-8 mr-3" |
| 132 | + placeholder="Enter TxId" value="95fa8f460851d7ad175e2e05711519cf796d77ff22ec346029ffabe9056cf04b" |
| 133 | + ></input> |
| 134 | + <button id="btnLoadTx" class="mr-3">Load Tx</button> |
| 135 | + <button id="btnExploreTx" class="mr-3">Show in Explorer</button> |
| 136 | + </div> |
| 137 | + <div class="row"> |
| 138 | + <label class="col-md-1">vin</label> |
| 139 | + <select class="col-md-2" id="vin"></select> |
| 140 | + <!-- <label class="col-md-1">vout</label> |
| 141 | + <select class="col-md-2" id="vout"></select> --> |
| 142 | + </div> |
135 | 143 | </div>
|
136 | 144 | </div>
|
137 | 145 |
|
138 | 146 | <div class="card">
|
139 |
| - <div class="card-header"><i class="fa fa-unlock fa-lg mt-4"></i>Unlock Script (aka ScriptSig from Transaction Input vin)</div> |
| 147 | + <div class="card-header"> |
| 148 | + <i class="fa fa-unlock fa-lg mt-4"></i> |
| 149 | + <span>Unlock Script (aka ScriptSig from Transaction Input vin)</span> |
| 150 | + <button class="btn btn-primary float-md-right" type="button" data-toggle="collapse" data-target="#hexUnlock"> |
| 151 | + Hex |
| 152 | + </button> |
| 153 | + </div> |
140 | 154 | <div class="card-body">
|
141 | 155 | <textarea id="txtUnlock" class="colspan=12 w-100">OP_1 OP_2 OP_MUL</textarea>
|
142 | 156 | </div>
|
| 157 | + <div class="collapse" id="hexUnlock"> |
| 158 | + <div class="card-body"> |
| 159 | + <textarea id="txtUnlockHex" class="colspan=12 w-100"></textarea> |
| 160 | + </div> |
| 161 | + </div> |
143 | 162 | </div>
|
144 | 163 |
|
145 | 164 | <div class="card">
|
146 |
| - <div class="card-header"><i class="fa fa-lock fa-lg mt-4"></i>Locking Script (aka ScriptPubKey from Transaction Output vout)</div> |
| 165 | + <div class="card-header"> |
| 166 | + <i class="fa fa-lock fa-lg mt-4"></i> |
| 167 | + <span>Locking Script (aka ScriptPubKey from Transaction Output vout)</span> |
| 168 | + <button class="btn btn-primary float-md-right" type="button" data-toggle="collapse" data-target="#hexLock"> |
| 169 | + Hex |
| 170 | + </button> |
| 171 | + </div> |
147 | 172 | <div class="card-body">
|
148 | 173 | <textarea id="txtLock" class="colspan=12 w-100">OP_2 OP_EQUAL</textarea>
|
149 | 174 | </div>
|
150 |
| - </div> |
| 175 | + <div class="collapse" id="hexLock"> |
| 176 | + <div class="card-body"> |
| 177 | + <textarea id="txtLockHex" class="colspan=12 w-100"></textarea> |
| 178 | + </div> |
| 179 | + </div> |
| 180 | + </div> |
151 | 181 |
|
152 | 182 | <div class="pb-3">
|
153 | 183 | <button id="scriptRun">Run Script</button>
|
|
194 | 224 | integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
|
195 | 225 | crossorigin="anonymous"></script>
|
196 | 226 | <script src="node_modules/popper.js/dist/umd/popper.min.js"></script>
|
197 |
| - <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
198 |
| - <script src="node_modules/pace-progress/pace.min.js"></script> |
| 227 | + <script src="dist/bootstrap.min.js"></script> |
| 228 | + <script src="dist/pace.min.js"></script> |
199 | 229 | <script src="node_modules/perfect-scrollbar/dist/perfect-scrollbar.min.js"></script>
|
200 |
| - <script src="node_modules/@coreui/coreui/dist/js/coreui.min.js"></script> |
| 230 | + <script src="dist/coreui.min.js"></script> |
201 | 231 | <!-- Plugins and scripts required by this view-->
|
202 |
| - <script src="node_modules/chart.js/dist/Chart.min.js"></script> |
| 232 | + <script src="js/charts.js"></script> |
203 | 233 | <script src="node_modules/@coreui/coreui-plugin-chartjs-custom-tooltips/dist/js/custom-tooltips.min.js"></script>
|
204 | 234 | <script src="js/main.js"></script>
|
205 | 235 |
|
|
209 | 239 | runScript()
|
210 | 240 | })
|
211 | 241 |
|
| 242 | + $('#btnExploreTx').click( (clk) => { |
| 243 | + let txid = $('#txtTxid').val() |
| 244 | + if (txid) { |
| 245 | + window.open(`https://bchsvexplorer.com/tx/${txid}`) |
| 246 | + } |
| 247 | + }) |
| 248 | + |
| 249 | + $('#txtLock').change(() => { |
| 250 | + let scriptLock = bsv.Script($('#txtLock').val()) |
| 251 | + $('#txtLockHex').val(scriptLock.toBuffer().toString('hex')) |
| 252 | + }) |
| 253 | + |
| 254 | + $('#txtUnlock').change(() => { |
| 255 | + let scriptLock = bsv.Script($('#txtUnlock').val()) |
| 256 | + $('#txtUnlockHex').val(scriptLock.toBuffer().toString('hex')) |
| 257 | + }) |
| 258 | + |
| 259 | + let thisTransaction = null |
| 260 | + let otherTransaction = null |
| 261 | + |
212 | 262 | $('#btnLoadTx').click( (clk) => {
|
213 | 263 | let txid = $('#txtTxid').val()
|
214 | 264 | if (txid) {
|
215 | 265 | rawtx(txid).then( unlockingTx => {
|
216 |
| - let utx = unlockingTx.data |
217 |
| - console.log(utx) |
218 |
| - let selectedVin = utx.vin[0] |
219 |
| - console.log(selectedVin) |
220 |
| - $('#txtUnlock').val(selectedVin.scriptSig.asm) |
221 |
| - rawtx(selectedVin.txid).then( lockingTx => { |
222 |
| - $('#txtLock').val(lockingTx.data.vout[selectedVin.vout].scriptPubKey.asm) |
223 |
| - runScript() |
| 266 | + thisTransaction = unlockingTx.data |
| 267 | + console.log(thisTransaction) |
| 268 | + thisTransaction.vin.forEach( i => { |
| 269 | + $('#vin').append($("<option/>",{value: i.vout, text: `${i.vout}:${i.txid}`})) |
224 | 270 | })
|
| 271 | + whenVinSelected(0) |
| 272 | + // thisTransaction.vout.forEach( i => { |
| 273 | + // $('#vout').append($("<option/>",{value: i.n, text: i.value})) |
| 274 | + // }) |
225 | 275 | })
|
226 | 276 | }
|
227 | 277 | })
|
| 278 | + |
| 279 | + $('#vin').change( () => { |
| 280 | + whenVinSelected(parseInt($('#vin').val(),10)) |
| 281 | + }) |
| 282 | + |
| 283 | + // $('#vout').change( () => { |
| 284 | + // whenVoutSelected(parseInt($('#vout').val(),10)) |
| 285 | + // }) |
| 286 | + |
| 287 | + const whenVinSelected = (vinIndex) => { |
| 288 | + let selectedVin = thisTransaction.vin[vinIndex] |
| 289 | + console.log(selectedVin) |
| 290 | + let scriptUnlock = bsv.Script.fromHex(selectedVin.scriptSig.hex) |
| 291 | + $('#txtUnlock').val(scriptUnlock.toString()) |
| 292 | + $('#txtUnlockHex').val(selectedVin.scriptSig.hex) |
| 293 | + rawtx(selectedVin.txid).then( lockingTx => { |
| 294 | + otherTransaction = lockingTx.data |
| 295 | + let scriptLock = bsv.Script.fromHex(lockingTx.data.vout[selectedVin.vout].scriptPubKey.hex) |
| 296 | + $('#txtLock').val(scriptLock.toString()) |
| 297 | + $('#txtLockHex').val(lockingTx.data.vout[selectedVin.vout].scriptPubKey.hex) |
| 298 | + runScript() |
| 299 | + }) |
| 300 | + } |
228 | 301 | })
|
229 | 302 |
|
| 303 | + // const whenVoutSelected = (voutIndex) => { |
| 304 | + // let selectedVout = thisTransaction.vin[vinIndex] |
| 305 | + // console.log(selectedVout) |
| 306 | + // let scriptLock = bsv.Script.fromHex(selectedVout.scriptPubKey.hex) |
| 307 | + // $('#txtLock').val(scriptLock.toString()) |
| 308 | + // rawtx(selectedVin.txid).then( lockingTx => { |
| 309 | + // otherTransaction = lockingTx.data |
| 310 | + // let scriptLock = bsv.Script.fromHex(lockingTx.data.vout[selectedVin.vout].scriptPubKey.hex) |
| 311 | + // //$('#txtLock').val(lockingTx.data.vout[selectedVin.vout].scriptPubKey.asm) |
| 312 | + // $('#txtLock').val(scriptLock.toString()) |
| 313 | + // runScript() |
| 314 | + // }) |
| 315 | + // } |
| 316 | + |
230 | 317 | const rawtx = async (tx) => {
|
231 | 318 | if (!tx) {
|
232 | 319 | console.log("nothing passed to rawtx!")
|
|
0 commit comments