forked from blockcypher/explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction_overview.html
415 lines (360 loc) · 14.6 KB
/
transaction_overview.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
{% extends "base.html" %}
{% load i18n %}
{% load humanize %}
{% load btc_formats %}
{% load static %}
{% block title %}
{% blocktrans with currency_name=coin_symbol|coin_symbol_to_currency_name tx_hash=tx_hash %}
{{ currency_name }} Transaction {{ tx_hash }}
{% endblocktrans %}
{% endblock title %}
{% block meta_description %}
{% satoshis_to_user_units_trimmed transaction.total 'btc' coin_symbol %}
transacted in TX {{ tx_hash }}
{% if is_coinbase_tx %}
(fees were {% satoshis_to_user_units_trimmed fee_in_satoshis_coinbase 'btc' coin_symbol %}).
{% else %}
(fees were {% satoshis_to_user_units_trimmed fee_in_satoshis 'btc' coin_symbol %}).
{% endif %}
{% if transaction.block_hash %}
This transaction was mined in {{ coin_symbol|coin_symbol_to_currency_name }} block {{ transaction.block_hash }}.
{% endif %}
{{ transaction.vin_sz }} input{{ transaction.vin_sz|pluralize }}
consumed,
{{ transaction.vout_sz }} output{{ transaction.vout_sz|pluralize }}
created.
{% endblock meta_description %}
{% block page_header %}
<h1>
<i class="fa fa-exchange"></i>
{{ coin_symbol|coin_symbol_to_display_name }} Transaction
</h1>
<h2 class="tagline wrapit semi">{{ tx_hash }}</h2>
{% endblock page_header %}
{% block content %}
<div class="section">
<div class="container">
{% if transaction.double_spend_tx %}
{% if transaction.confirmations < 6 %}
<div class="alert alert-danger" role="alert">
<i class="fa fa-exclamation-triangle"></i>
WARNING: This transaction has been double-spent by
<a href="{% url 'transaction_overview' coin_symbol transaction.double_spend_tx %}">{{ transaction.double_spend_tx|truncatechars:"32" }}</a>,
be extremely careful when accepting this transaction!
</div>
{% else %}
<div class="alert alert-danger" role="alert">
<i class="fa fa-exclamation-triangle"></i>
WARNING: This transaction had an attempted double-spent by
<a href="{% url 'transaction_overview' coin_symbol transaction.double_spend_tx %}">{{ transaction.double_spend_tx|truncatechars:"32" }}</a>,
but was still confirmed.
</div>
{% endif %}
{% endif %}
{% if transaction.data_protocol %}
<div id="dp-section" class="row">
<div class="alert alert-info" role="alert">
<i class="fa fa-exclamation-triangle"></i>
<strong>
{% if transaction.data_protocol == 'unknown' %}
Data Embedded in Transaction with Unknown Protocol
{% elif transaction.data_protocol == 'blockchainid' %}
Stacks Blockchain Transaction
{% elif transaction.data_protocol == 'openassets' %}
Open Assets Transaction
{% elif transaction.data_protocol == 'factom' %}
Factom Transaction
{% elif transaction.data_protocol == 'colu' %}
Colu Transaction
{% elif transaction.data_protocol == 'coinspark' %}
CoinSpark Transaction
{% elif transaction.data_protocol == 'omni' %}
Omni Transaction
{% else %}
{# Catch all in case more are added #}
{{ transaction.data_protocol }} Transaction
{% endif %}
</strong>
(<a href="http://www.blockcypher.com/dev/bitcoin/#tx">what's this?</a>)
<br />
<p>
{% with data_dict=transaction.outputs|txn_outputs_to_data_dict %}
{% if data_dict.data_hex or data_dict.data_string %}
{% if data_dict.data_string %}
<strong>String</strong>: {{ data_dict.data_string }} <br />
{% endif %}
{% if data_dict.data_hex %}
<strong>Hex</strong>: {{ data_dict.data_hex }}
{% endif %}
{% endif %}
{% endwith %}
</p>
</div>
</div>
{% endif %}
<div class="dash dash-4">
<ul>
{% if is_coinbase_tx %}
<li>
<span class="dash-label">Amount Transacted</span><br>
{% satoshis_to_user_units_trimmed total_satoshis_coinbase tcp__user_units coin_symbol %}
</li>
<li>
<span class="dash-label">Fees Collected</span><br>
{% satoshis_to_user_units_trimmed fee_in_satoshis_coinbase tcp__user_units coin_symbol %}
</li>
{% else %}
<li>
<span class="dash-label">Amount Transacted</span><br>
{% satoshis_to_user_units_trimmed total_satoshis tcp__user_units coin_symbol %}
</li>
<li>
<span class="dash-label">Fees</span><br>
{% satoshis_to_user_units_trimmed fee_in_satoshis tcp__user_units coin_symbol %}
</li>
{% endif %}
<li>
<span class="dash-label" title="{{ time_to_use|date:"r" }}">
Received
</span><br>
<i class="fa fa-clock-o"></i>
<time class="timeago" datetime="{{ time_to_use|date:'Y-m-d\TH:i:s' }}Z">
{{ time_to_use|date:'Y-m-d H:i' }} GMT
</time>
</li>
<li>
<span class="dash-label">
Confirmations
<button
id='confs-hover'
type='button'
class='btn-link'
data-container='body'
data-toggle='popover'
data-placement='top'
data-html='true'
data-content='
<strong>{{ transaction.confirmations|intcomma }}</strong> confirmations.
<br />
Anything over 6 confirmations is considered completed and irreversible.
'>
<i class="fa fa-info-circle"></i>
</button>
</span><br>
{% if transaction.confirmations >= 6 %}
<span id="conf-section" class="confirmed">
<i class="fa fa-lock"></i>
<span id="num-confs">6+</span>
</span>
{% elif transaction.confirmations > 0 and transaction.confirmations < 6 %}
<span id="conf-section" class="pending">
<i class="fa fa-unlock"></i>
<span id="num-confs">{{ transaction.confirmations|intcomma }}/6</span>
</span>
{% else %}
<span id="conf-section" class="unconfirmed">
<i class="fa fa-unlock"></i>
<span id="num-confs">{{ transaction.confirmations|intcomma }}/6</span>
</span>
{% endif %}
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="section">
<div class="container">
<div class="row">
<div {% if transaction.block_hash or transaction.double_spend %} style="display:none;"{% endif %} id="confidence-section" class="col-md-3 text-center">
<strong>Confidence</strong>
<button id="confidence-popover" type='button' class='btn-link'>
<i class="fa fa-info-circle"></i>
</button>
<div class="circle-chart">
<div id="confidence-widget" class="fill" style="height:{{ confidence_pct_scaled }}%;"></div>
<span id="confidence-text" class="val">{{ confidence_pct|floatformat:2 }}%</span>
</div>
</div>
<div {% if transaction.block_hash or transaction.double_spend %} style="display:none;"{% endif %} id="preference-section" class="col-md-3 text-center">
<strong>Miner Preference</strong>
<div class="circle-chart">
<div class="fill {{ transaction.preference }}"></div>
<span class="val">{{ transaction.preference }}</span>
</div>
</div>
{% if transaction.block_hash %}
<p class="text-center">
<button type="button" class="btn btn-primary" data-toggle="collapse" data-target="#advanced-details">
Advanced Details
<b class="caret"></b>
</button>
</p>
<div class="col-md-12 collapse" id="advanced-details">
{% else %}
<div class="col-md-6">
{% endif %}
<div class="table-responsive">
<table class="table">
{% if transaction.block_hash %}
<tr>
<th>Block Hash</th>
<td>
<a href="{% url 'block_overview' coin_symbol transaction.block_hash %}" class="hidden-xs">{{ transaction.block_hash }}</a>
<a href="{% url 'block_overview' coin_symbol transaction.block_hash %}" class="visible-xs">See Block</a>
</td>
</tr>
<tr>
<th>Block Height</th>
<td>
<a href="{% url 'block_overview' coin_symbol transaction.block_height %}">{{ transaction.block_height|intcomma }}</a>
</td>
</tr>
{% if transaction.block_index %}
{# hack, this should always exist but doesn't appear to at least in the case of coinbase transactions #}
<tr>
<th>Transaction Index</th>
<td>
{{ transaction.block_index|intcomma }}
(<a href="{% url 'block_ordered_tx' coin_symbol transaction.block_height transaction.block_index %}">permalink</a>)
</td>
</tr>
{% endif %}
{% endif %}
{% if is_coinbase_tx and coinbase_msg %}
<tr>
<th>Coinbase Message:</th>
<td class="wrapit">{{ coinbase_msg }}</td>
</tr>
{% endif %}
<tr>
<th>Size</th>
<td>{{ transaction.size }} bytes</td>
</tr>
<tr>
<th>Lock Time</th>
<td>{{ transaction.lock_time }}</td>
</tr>
<tr>
<th>Version</th>
<td>{{ transaction.ver }}</td>
</tr>
{% if transaction.relayed_by %}
<tr>
<th>Relayed By:</th>
<td>{{ transaction.relayed_by }}</td>
</tr>
{% endif %}
<tr>
<td colspan="2" class="text-center">
<a href="{{ api_url }}" class="btn btn-default">
<i class="fa fa-code"></i>
API Call
</a>
<a href="http://dev.blockcypher.com/#transactions" class="btn btn-default">
<i class="fa fa-external-link"></i>
API Docs
</a>
</td>
</tr>
</table>
</div>
{# if statement div: #}
</div>
</div> {# row #}
</div> {# section #}
</div> {# container #}
<div class="col-md-12">
<h3>Details</h3>
</div>
<div class="clearfix"></div>
{% with force_include_tx_amount=False show_tx_hash=False show_num_confirmations=False num_inouts_to_display=1000 %}
{% include "partials/tx_hash.html" %}
{% endwith %}
{% url 'add_metadata_to_tx' coin_symbol tx_hash as add_metadata_uri %}
{% include "partials/metadata.html" %}
</div> {# opening section #}
</div> {# opening container #}
{% endblock content %}
{% block extra_js %}
<script src="{% static "js/jquery.timeago.js" %}"></script>
<script>
{% if transaction.receive_cnt > 0 %}
var memoryPools = {{ transaction.receive_cnt }};
{% else %}
var memoryPools = 0;
{% endif %}
var doubleSpend = {% if transaction.double_spend %}"YES"{% else %}"No"{% endif %};
var confidence_checks = 0;
function poll_confidence() {
var CONFIDENCE_TIMEOUT_MS = 2000;
$.ajax({
type: 'get',
url: '/{{ coin_symbol }}/tx-confidence/{{ tx_hash }}/',
success: function (data) {
console.log('Confidence API Call Success');
console.log(data);
confidence_checks += 1;
CONFIDENCE_TIMEOUT_MS += 1000;
// Update #s
$("#confidence-widget").height(data['confidence_pct_scaled'] + '%');
$("#confidence-text").text(data['confidence_pct'] + "%");
$('#receive-cnt').text(data['receive_cnt']);
memoryPools = data['receive_cnt'];
{# this code not invoked unless there was previously no double-spend #}
if (data['double_spend_detected']) {
location.reload();
}
if (confidence_checks < 5) {
setTimeout(poll_confidence, CONFIDENCE_TIMEOUT_MS);
}
},
error: function(data) {
console.log('Confidence API Call Failure');
confidence_checks += 1;
if (confidence_checks < 5) {
setTimeout(poll_confidence, 10000);
}
}
});
}
$(document).ready(function(){
$("time.timeago").timeago();
{% if transaction.confirmations == 0 and transaction.double_spend == False %}
poll_confidence()
{% endif %}
function popoverContent(){
var html = '';
html += '<span{% if transaction.block_hash %} style="display:none;"{% endif %}>' +
'<b>Double-Spend Detected:</b> ' +
'<span id="ds-detected">No</span>' +
'</span><br>' +
'<span{% if transaction.block_hash %} style="display:none;"{% endif %} id="pools-section">' +
'<b>Memory Pools With Tx:</b> <span id="receive-cnt">'+memoryPools+'</span>'+
'</span><br />' +
'<span><a href="http://dev.blockcypher.com/#confidence-factor">How Calculated</a></span>';
return html;
}
//init popover
$('[data-toggle="popover"]').popover({'html': true});
//init confidence popover
$('#confidence-popover').popover({
'html':true,
'placement':'top',
'trigger': 'click',
'content': function () {
return popoverContent();
}
})
if (window.location.hash == '#advanced-details') {
$('#advanced-details').collapse('show');
}
// Highlight an input or output by index num
if (window.location.hash.slice(1,13) == 'output-index') {
$(window.location.hash).attr('style', "background-color:#eee;")
}
if (window.location.hash.slice(1,8) == 'spentby') {
$(window.location.hash).attr('style', "background-color:#eee;")
}
fetch_metadata('{{ coin_symbol }}', 'tx', '{{ tx_hash }}');
})
</script>
{% endblock extra_js %}