transactions limit api
This commit is contained in:
3
api.php
3
api.php
@@ -68,8 +68,9 @@ elseif($q=="getPendingBalance"){
|
||||
}
|
||||
elseif($q=="getTransactions"){
|
||||
$account=san($data['account']);
|
||||
$limit=intval($data['limit']);
|
||||
$transactions=$acc->get_mempool_transactions($account);
|
||||
$transactions=array_merge($transactions, $acc->get_transactions($account));
|
||||
$transactions=array_merge($transactions, $acc->get_transactions($account,$limit));
|
||||
api_echo($transactions);
|
||||
|
||||
}
|
||||
|
||||
@@ -88,12 +88,14 @@ class Account {
|
||||
return number_format($rez,8,".","");
|
||||
|
||||
}
|
||||
public function get_transactions($id){
|
||||
public function get_transactions($id,$limit=100){
|
||||
global $db;
|
||||
$block=new Block;
|
||||
$current=$block->current();
|
||||
$public_key=$this->public_key($id);
|
||||
$res=$db->run("SELECT * FROM transactions WHERE dst=:dst or public_key=:src ORDER by height DESC LIMIT 100",array(":src"=>$public_key, ":dst"=>$id));
|
||||
$limit=intval($limit);
|
||||
if($limit>100||$limit<1) $limit=100;
|
||||
$res=$db->run("SELECT * FROM transactions WHERE dst=:dst or public_key=:src ORDER by height DESC LIMIT :limit",array(":src"=>$public_key, ":dst"=>$id, ":limit"=>$limit));
|
||||
|
||||
$transactions=array();
|
||||
foreach($res as $x){
|
||||
|
||||
5
util.php
5
util.php
@@ -135,6 +135,11 @@ echo "Mempool size: $res\n";
|
||||
$res=$db->single("SELECT balance FROM accounts WHERE id=:id OR public_key=:id2 LIMIT 1",array(":id"=>$id, ":id2"=>$id));
|
||||
|
||||
echo "Balance: ".number_format($res)."\n";
|
||||
}elseif($cmd=="block"){
|
||||
$id=san($argv[2]);
|
||||
$res=$db->row("SELECT * FROM blocks WHERE id=:id OR height=:id2 LIMIT 1",array(":id"=>$id, ":id2"=>$id));
|
||||
|
||||
var_dump($res);
|
||||
|
||||
} else {
|
||||
echo "Invalid command\n";
|
||||
|
||||
Reference in New Issue
Block a user