forked from CalexCore/amity.rpc.php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgettransactionpool.php
60 lines (49 loc) · 1.46 KB
/
gettransactionpool.php
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
<?php
//*desc: Gets a list of transactions in the pool
require_once('./lib/config.php');
$params = array(
"json_only" => true
);
$s = json_encode($params);
$ch = curl_init();
$url = 'http://'.HOST.':'.PORT.'/get_transaction_pool';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $s);
$obj=curl_exec($ch);
curl_close($ch);
$json = json_decode($obj);
if (!isset($json->transactions)) {
echo $obj;
return;
}
$txs = $json->transactions;
$ski = $json->spent_key_images;
$formatted = array();
foreach ($txs as &$x)
{
$tx = new stdClass();
$f = $x->tx_json;
trim($f,'"');
$f = str_replace(array("\\n", "\\r"), '', $f);
$f = stripslashes($f);
$tx->double_spend_seen = $x->double_spend_seen;
$tx->do_not_relay = $x->do_not_relay;
$tx->fee = $x->fee;
$tx->id_hash = $x->id_hash;
$tx->kept_by_block = $x->kept_by_block;
$tx->last_failed_height = $x->last_failed_height;
$tx->last_failed_id_hash = $x->last_failed_id_hash;
$tx->last_relayed_time = $x->last_relayed_time;
$tx->max_used_block_height = $x->max_used_block_height;
$tx->receive_time = $x->receive_time;
$tx->relayed = $x->relayed;
$tx->json = json_decode($f);
$formatted[] = $tx;
}
$res = new stdClass();
$res->spent_key_images = $ski;
$res->transactions = $formatted;
print_r(json_encode($res));
?>