forked from janoside/btc-rpc-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction.pug
304 lines (253 loc) · 11.9 KB
/
transaction.pug
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
extends layout
block headContent
title Transaction #{txid}
style.
.field {
word-wrap: break-word;
}
block content
if (result && result.getrawtransaction)
h1(class="h3 word-wrap") Transaction
br
small(class="monospace") #{txid}
hr
ul(class='nav nav-tabs mb-3')
li(class="nav-item")
a(data-toggle="tab", href="#tab-details", class="nav-link active", role="tab") Details
li(class="nav-item")
a(data-toggle="tab", href="#tab-scripts", class="nav-link", role="tab") Scripts
li(class="nav-item")
a(data-toggle="tab", href="#tab-json", class="nav-link", role="tab") JSON
- DecimalRounded = Decimal.clone({ precision: 4, rounding: 2 })
- var totalInputValue = new Decimal(0);
if (result.getrawtransaction.vin[0].coinbase)
- totalInputValue = totalInputValue.plus(new Decimal(coinConfig.blockRewardFunction(result.getblock.height)));
each txInput, txInputIndex in result.txInputs
if (txInput)
- var vout = txInput.vout[result.getrawtransaction.vin[txInputIndex].vout];
if (vout.value)
- totalInputValue = totalInputValue.plus(new Decimal(vout.value));
- var totalOutputValue = new Decimal(0);
each vout, voutIndex in result.getrawtransaction.vout
- totalOutputValue = totalOutputValue.plus(new Decimal(vout.value));
div(class="tab-content")
div(id="tab-details", class="tab-pane active", role="tabpanel")
if (global.specialTransactions && global.specialTransactions[txid])
div(class="alert alert-primary shadow-sm", style="padding-bottom: 0;")
div(class="float-left", style="width: 55px; height: 55px; font-size: 18px;")
i(class="fas fa-certificate fa-2x", style="margin-top: 10px;")
h4(class="alert-heading h6 font-weight-bold") #{coinConfig.name} Fun
// special transaction info
- var stInfo = global.specialTransactions[txid];
if (stInfo.alertBodyHtml)
p
span !{stInfo.alertBodyHtml}
if (stInfo.referenceUrl && stInfo.referenceUrl.trim().length > 0 && stInfo.alertBodyHtml.indexOf(stInfo.referenceUrl) == -1)
span
a(href=stInfo.referenceUrl) Read more
else
p
span #{stInfo.summary}
if (stInfo.referenceUrl && stInfo.referenceUrl.trim().length > 0)
span
a(href=stInfo.referenceUrl) Read more
- var isTxConfirmed = true;
if (!result.getrawtransaction.confirmations || result.getrawtransaction.confirmations == 0)
- isTxConfirmed = false;
div(class="card mb-3 shadow-sm")
div(class="card-header")
span(class="h6") Summary
div(class="card-body")
if (!isTxConfirmed)
div(class="row")
div(class="summary-table-label") Status
div(class="summary-table-content monospace")
span(class="text-warning") Unconfirmed
if (isTxConfirmed)
div(class="row")
div(class="summary-table-label") Block
div(class="summary-table-content monospace")
a(href=("/block/" + result.getrawtransaction.blockhash)) #{result.getrawtransaction.blockhash}
if (result.getblock.height)
br
span (##{result.getblock.height.toLocaleString()})
if (isTxConfirmed)
div(class="row")
div(class="summary-table-label") Timestamp
div(class="summary-table-content monospace")
if (result.getrawtransaction.time)
td(class="monospace") #{moment.utc(new Date(result.getrawtransaction["time"] * 1000)).format("Y-MM-DD HH:mm:ss")} utc
- var timeAgoTime = result.getrawtransaction["time"];
include includes/time-ago.pug
div(class="row")
div(class="summary-table-label") Version
div(class="summary-table-content monospace") #{result.getrawtransaction.version}
div(class="row")
div(class="summary-table-label") Size
div(class="summary-table-content monospace")
if (result.getrawtransaction.vsize != result.getrawtransaction.size)
span #{result.getrawtransaction.vsize.toLocaleString()}
span.border-dotted(title="Virtual bytes", data-toggle="tooltip") vB
br
span(class="text-muted") (#{result.getrawtransaction.size.toLocaleString()} B)
else
span #{result.getrawtransaction.size.toLocaleString()} B
if (result.getrawtransaction.locktime > 0)
div(class="row")
div(class="summary-table-label") Locktime
div(class="summary-table-content monospace")
if (result.getrawtransaction.locktime < 500000000)
span Spendable in block
a(href=("/block-height/" + result.getrawtransaction.locktime)) #{result.getrawtransaction.locktime.toLocaleString()}
span or later
a(href="https://bitcoin.org/en/developer-guide#locktime-and-sequence-number", data-toggle="tooltip", title="More info about locktime", target="_blank")
i(class="fas fa-info-circle")
else
span Spendable after #{moment.utc(new Date(result.getrawtransaction.locktime * 1000)).format("Y-MM-DD HH:mm:ss")} (utc)
a(href="https://bitcoin.org/en/developer-guide#locktime-and-sequence-number", data-toggle="tooltip", title="More info about locktime", target="_blank")
i(class="fas fa-info-circle")
if (isTxConfirmed)
div(class="row")
div(class="summary-table-label") Confirmations
div(class="summary-table-content monospace")
if (!result.getrawtransaction.confirmations || result.getrawtransaction.confirmations == 0)
strong(class="text-warning") 0 (unconfirmed)
else if (result.getrawtransaction.confirmations < 6)
strong(class="text-warning") #{result.getrawtransaction.confirmations}
else
strong(class="text-success") #{result.getrawtransaction.confirmations.toLocaleString()}
if (result.getrawtransaction.vin[0].coinbase)
div(class="row")
div(class="summary-table-label") Fees Collected
div(class="summary-table-content monospace")
- var currencyValue = new Decimal(totalOutputValue).minus(totalInputValue);
include includes/value-display.pug
- var blockRewardMax = coinConfig.blockRewardFunction(result.getblock.height);
if (parseFloat(totalOutputValue) < parseFloat(blockRewardMax))
div(class="row")
div(class="summary-table-label")
span.border-dotted(data-toggle="tooltip" title="The miner of this transaction's block failed to collect this value. As a result, it is lost.") Fees Destroyed
div(class="summary-table-content monospace text-danger")
- var currencyValue = new Decimal(blockRewardMax).minus(totalOutputValue);
include includes/value-display.pug
if (minerInfo)
- var minerInfo = utils.getMinerFromCoinbaseTx(result.getrawtransaction);
div(class="row")
div(class="summary-table-label") Miner
div(class="summary-table-content monospace")
if (minerInfo)
span #{minerInfo.name}
if (minerInfo.identifiedBy)
span(data-toggle="tooltip", title=("Identified by: " + minerInfo.identifiedBy))
i(class="fas fa-info-circle")
else
span ?
span(data-toggle="tooltip", title="Unable to identify miner")
i(class="fas fa-info-circle")
else
- var feePaid = new Decimal(totalInputValue).minus(totalOutputValue);
div(class="row")
div(class="summary-table-label") Fee Paid
div(class="summary-table-content monospace")
- var currencyValue = feePaid;
include includes/value-display.pug
if (feePaid > 0)
span.ml-2(title=(utils.formatCurrencyAmount(totalInputValue, currencyFormatType) + " - " + utils.formatCurrencyAmount(totalOutputValue, currencyFormatType)), data-toggle="tooltip")
i(class="fas fa-ellipsis-h")
if (feePaid > 0)
div(class="row")
div(class="summary-table-label") Fee Rate
div(class="summary-table-content monospace")
if (result.getrawtransaction.vsize != result.getrawtransaction.size)
span #{utils.addThousandsSeparators(new DecimalRounded(totalInputValue).minus(totalOutputValue).dividedBy(result.getrawtransaction.vsize).times(100000000))} sat/
span.border-dotted(title="Virtual bytes" data-toggle="tooltip") vB
br
span(class="text-muted") (#{utils.addThousandsSeparators(new DecimalRounded(totalInputValue).minus(totalOutputValue).dividedBy(result.getrawtransaction.size).times(100000000))} sat/B)
if (result.getrawtransaction.vin[0].coinbase)
div(class="card mb-3 shadow-sm")
div(class="card-header")
h2(class="h6 mb-0") Coinbase
div(class="card-body")
h6 Hex
div(class="bg-light px-4 py-3 mb-3")
span(class="monospace word-wrap") #{result.getrawtransaction.vin[0].coinbase}
h6 Decoded
div(class="bg-light px-4 py-3 mb-3")
span(class="monospace word-wrap") #{utils.hex2ascii(result.getrawtransaction.vin[0].coinbase)}
div(class="card mb-3 shadow-sm")
div(class="card-header")
h2(class="h6 mb-0")
span #{result.getrawtransaction.vin.length.toLocaleString()}
if (result.getrawtransaction.vin.length == 1)
span Input
else
span Inputs
span ,
span #{result.getrawtransaction.vout.length.toLocaleString()}
if (result.getrawtransaction.vout.length == 1)
span Output
else
span Outputs
div(class="card-body")
- var tx = result.getrawtransaction;
- var txInputs = result.txInputs;
- var blockHeight = -1;
if (result && result.getblock)
- blockHeight = result.getblock.height;
include includes/transaction-io-details.pug
- var fontawesomeInputName = "sign-in-alt";
- var fontawesomeOutputName = "sign-out-alt";
div(id="tab-scripts", class="tab-pane", role="tabpanel")
div(class="card mb-3 shadow-sm")
div(class="card-header")
span(class="h6") Input Scripts
div(class="card-body")
table(class="table table-striped mb-5")
thead
tr
th(style="width: 50px;")
th Script Sig (asm)
tbody
each vin, vinIndex in result.getrawtransaction.vin
tr
th(class="pl-0")
a(data-toggle="tooltip", title=("Input #" + (vinIndex + 1)), style="white-space: nowrap;")
i(class=("fas fa-" + fontawesomeInputName + " mr-2"))
span #{(vinIndex + 1)}
td(class="word-wrap text-break monospace")
if (vin.scriptSig && vin.scriptSig.asm)
span #{vin.scriptSig.asm}
else if (vin.coinbase)
div(class="monospace", style="line-height: 1.75em;")
span(class="rounded bg-primary text-white px-2 py-1 mr-2") coinbase
br
span #{vin.coinbase}
br
span(class="text-muted") (decoded) #{utils.hex2ascii(vin.coinbase)}
div(class="card mb-3 shadow-sm")
div(class="card-header")
span(class="h6") Output Scripts
div(class="card-body")
table(class="table table-striped")
thead
tr
th(style="width: 50px;")
th Script Pub Key (asm)
tbody
each vout, voutIndex in result.getrawtransaction.vout
tr
th(class="pl-0")
a(data-toggle="tooltip", title=("Output #" + (voutIndex + 1)), style="white-space: nowrap;")
i(class=("fas fa-" + fontawesomeOutputName + " mr-2"))
span #{(voutIndex + 1)}
td(class="word-wrap monospace")
if (vout.scriptPubKey && vout.scriptPubKey.asm)
span #{vout.scriptPubKey.asm}
if (vout.scriptPubKey.asm.startsWith("OP_RETURN"))
br
span(class="text-muted") (decoded) #{utils.hex2ascii(vout.scriptPubKey.asm)}
div(id="tab-json", class="tab-pane", role="tabpanel")
div(class="highlight")
pre
code(class="json bg-light", data-lang="json") #{JSON.stringify(result.getrawtransaction, null, 4)}
//pre #{JSON.stringify(result.txInputs, null, 4)}