forked from phpcoinn/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtx.php
More file actions
executable file
·209 lines (204 loc) · 6.63 KB
/
tx.php
File metadata and controls
executable file
·209 lines (204 loc) · 6.63 KB
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
<?php
require_once dirname(__DIR__)."/apps.inc.php";
require_once ROOT. '/web/apps/explorer/include/functions.php';
define("PAGE", true);
define("APP_NAME", "Explorer");
$id = $_GET['id'];
$tx = Transaction::get_transaction($id);
$tx_height = $tx['height'];
$fee_ratio = Blockchain::getFee($tx_height);
$mempool = false;
if(!$tx) {
$tx = Transaction::getMempoolById($id);
$tx_height = $tx['height'];
$mempool = true;
if(!$tx) {
header("location: /apps/explorer");
exit;
}
}
if(isset($_GET['action'])) {
$action = $_GET['action'];
if($action == "check") {
$tx = Transaction::getMempoolById($id);
if($tx) {
$tx = Transaction::getFromArray($tx);
$tx->mempool = true;
} else {
$tx = Transaction::getById($id);
}
$block = Block::getFromArray(Block::get($tx_height));
$res = $tx->verify($block, $err);
if($res) {
die("Transaction valid");
} else {
die("Transaction not valid $err");
}
}
}
?>
<?php
require_once __DIR__. '/../common/include/top.php';
?>
<ol class="breadcrumb m-0 ps-0 h4">
<li class="breadcrumb-item"><a href="/apps/explorer">Explorer</a></li>
<li class="breadcrumb-item">Transaction</li>
<li class="breadcrumb-item active text-truncate"><?php echo $tx['id'] ?></li>
</ol>
<div class="table-responsive">
<table class="table table-sm table-striped">
<tr>
<td>id</td>
<td><?php echo $tx['id'] ?></td>
</tr>
<tr>
<td>height</td>
<td><a href="/apps/explorer/block.php?height=<?php echo $tx['height'] ?>"><?php echo $tx['height'] ?></a></td>
</tr>
<tr>
<td>Block</td>
<td><?php echo explorer_block_link($tx['block']) ?></td>
</tr>
<tr>
<td>Confirmations</td>
<td><?php echo $tx['confirmations'] ?></td>
</tr>
<tr>
<td>Date</td>
<td>
<?php echo display_date($tx['date']) ?>
</td>
</tr>
<?php
if($tx['type']==TX_TYPE_REWARD || $tx['type']==TX_TYPE_FEE) {
$src= null;
} else {
$src = Account::getAddress($tx['public_key']);
}
?>
<tr>
<td>Source</td>
<td>
<?php if($src) { ?>
<?php echo explorer_address_link(Account::getAddress($tx['public_key'])) ?>
<?php } ?>
</td>
</tr>
<tr>
<td>Destination</td>
<td><?php echo explorer_address_link($tx['dst']) ?></td>
</tr>
<tr>
<td>Type</td>
<td>
<?php echo Transaction::typeLabel($tx['type']) ?> (<?php echo $tx['type'] ?>)
<?php
if($tx['type']==TX_TYPE_SC_CREATE || $tx['type']==TX_TYPE_SC_EXEC) {
echo '<a href="/apps/explorer/smart_contract.php?id='.$tx['dst'].'">'.$tx['dst'].'</a>';
}
if($tx['type']==TX_TYPE_SC_SEND) {
$src = Account::getAddress($tx['public_key']);
echo '<a href="/apps/explorer/smart_contract.php?id='.$src.'">'.$src.'</a>';
}
?>
</td>
</tr>
<tr>
<td>Value</td>
<td><?php echo $tx['val'] ?></td>
</tr>
<tr>
<td>Fee</td>
<td>
<?php echo $tx['fee'] ?>
<?php if($mempool) { ?>
(<?php echo number_format($fee_ratio,5) ?>)
<?php } ?>
</td>
</tr>
<tr>
<td>Message</td>
<td><?php echo safeDisplay($tx['message']) ?></td>
</tr>
<tr>
<td>Public key</td>
<td><?php echo $tx['public_key'] ?></td>
</tr>
<tr>
<td>Signature</td>
<td><?php echo $tx['signature'] ?></td>
</tr>
<tr>
<td>Data</td>
<td style="word-break: break-all"><?php echo $tx['data'] ?></td>
</tr>
</table>
<?php if ($tx['type']==TX_TYPE_SC_EXEC || $tx['type']==TX_TYPE_SC_SEND) {
$sc_data = json_decode(base64_decode($tx['message']), true);
if(!is_array($sc_data['params'])) {
$sc_data['params'] = [$sc_data['params']];
}
if($tx['type'] == TX_TYPE_SC_EXEC) {
$contract = $tx['dst'];
} else if ($tx['type'] == TX_TYPE_SC_SEND) {
$contract = Account::getAddress($tx['public_key']);
} else {
$contract = "?";
}
?>
<h3>Smart Contract</h3>
<div class="table-responsive">
<table class="table table-sm table-striped">
<tr>
<td>Contract</td>
<td>
<a href="/apps/explorer/smart_contract.php?id=<?php echo $contract ?>">
<?php echo $contract ?>
</a>
</td>
</tr>
<tr>
<td>Type</td>
<td>
<?php echo $tx['type'] ?> -
<?php echo Transaction::typeLabel($tx['type']) ?>
</td>
</tr>
<?php if($tx['type']==TX_TYPE_SC_EXEC) {
$src = Account::getAddress($tx['public_key']);
?>
<tr>
<td>Sender</td>
<td>
<?php echo explorer_address_link($src) ?>
</td>
</tr>
<?php } ?>
<?php if($tx['type']==TX_TYPE_SC_SEND) { ?>
<tr>
<td>Receiver</td>
<td>
<?php echo explorer_address_link($tx['dst']) ?>
</td>
</tr>
<?php } ?>
<tr>
<td>Amount</td>
<td><?php echo $tx['val'] ?></td>
</tr>
<tr>
<td>Method</td>
<td><?php echo $sc_data['method'] ?></td>
</tr>
<tr>
<td>Params</td>
<td><?php echo implode("<br/>", array_map('safeDisplay', $sc_data['params'])) ?></td>
</tr>
</table>
</div>
<?php } ?>
</div>
<a href="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?php echo $tx['id'] ?>&action=check" class="btn btn-info">Check</a>
<?php
require_once __DIR__ . '/../common/include/bottom.php';
?>