-
Notifications
You must be signed in to change notification settings - Fork 2
/
getTransactionPool.php
39 lines (34 loc) · 1.51 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
<?php
// Copyright (c) 2018, Gnock
// Copyright (c) 2018, The Masari Project
// Copyright (c) 2019, The Qwertycoin developers
//
// This file is part of Qwertycoin.
//
// Qwertycoin is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// License for more details.
//
include 'config/config.php';
$curl = curl_init();
$body = json_encode(array("jsonrpc" => "2.0", "id" => "0", "method" => "f_on_transactions_pool_json", "params" => ''));
curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://'.$daemonAddress.':'.$rpcPort.'/json_rpc', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $body));
$resp = curl_exec($curl);
//now get the Tx details
$jsonMempool = json_decode($resp, true);
$rawTransactions = $jsonMempool["result"]["transactions"];
$txHashes = array();
for($iTransaction = 0; $iTransaction < count($rawTransactions); ++$iTransaction){
$txHashes[] = $rawTransactions[$iTransaction]["hash"];
}
$body = json_encode(array(
'transactionHashes'=>$txHashes
));
curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://'.$daemonAddress.':'.$rpcPort.'/get_transaction_details_by_hashes', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $body));
$resp = curl_exec($curl);
$decodedJson = json_decode($resp, true);
curl_close($curl);
$jsonMempool = json_decode($resp, true);
header('Content-Type: application/json');
echo json_encode($jsonMempool['transactions']);