From 738848b7e9e1cbdc741547dd44969e3b6cff0785 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Mon, 30 May 2016 09:15:41 +0200 Subject: [PATCH] various small changes --- web/yaamp/core/rpc/wallet-rpc.php | 29 +++++++++++++++++------- web/yaamp/modules/site/admin_results.php | 5 ++-- web/yaamp/modules/site/coin_console.php | 8 ++++++- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/web/yaamp/core/rpc/wallet-rpc.php b/web/yaamp/core/rpc/wallet-rpc.php index 6feba54..3941bbf 100644 --- a/web/yaamp/core/rpc/wallet-rpc.php +++ b/web/yaamp/core/rpc/wallet-rpc.php @@ -8,6 +8,7 @@ class WalletRPC { private $rpc; // cache + private $account; private $accounts; private $info; private $height = 0; @@ -26,6 +27,7 @@ class WalletRPC { switch ($coin->rpcencoding) { case 'GETH': $this->type = 'Ethereum'; + $this->account = empty($coin->account) ? $coin->master_wallet : $coin->account; $this->rpc = new Ethereum($coin->rpchost, $coin->rpcport); break; default: @@ -46,9 +48,9 @@ class WalletRPC { // convert common methods used by yiimp switch ($method) { case 'getaccountaddress': - if (!isset($this->accounts)) - $this->accounts = $this->rpc->eth_accounts(); - return arraySafeVal($this->accounts, 0, $params); + if (!empty($params[0])) + return $params[0]; + return $this->account; case 'getinfo': if (!isset($this->info)) { $info = array(); @@ -88,14 +90,25 @@ class WalletRPC { $info['generate'] = $this->rpc->eth_mining(); $info['errors'] = ''; return $info; + case 'getblock': + $hash = (string) arraySafeVal($params,0); + $block = $this->rpc->eth_getBlockByHash($hash); + return $block; + case 'getblockhash': + $n = arraySafeVal($params,0); + $block = $this->rpc->eth_getBlockByNumber($n, true); + return $block->hash; + case 'gettransaction': + case 'getrawtransaction': + $txid = arraySafeVal($params,0,''); + $tx = $this->rpc->eth_getTransactionByHash($txid); + return $tx; + case 'getwork': + return false; //$this->rpc->eth_getWork(); auto enable miner! + // todo... case 'getpeerinfo': $peers = array(); return $peers; - case 'getwork': - return $this->rpc->eth_getWork(); - // todo... - case 'getblocktemplate': - return $this->rpc->eth_getWork(); case 'listtransactions': $txs = array(); return $txs; diff --git a/web/yaamp/modules/site/admin_results.php b/web/yaamp/modules/site/admin_results.php index 309f58e..7c74533 100644 --- a/web/yaamp/modules/site/admin_results.php +++ b/web/yaamp/modules/site/admin_results.php @@ -7,6 +7,7 @@ echo << end; @@ -87,8 +88,8 @@ foreach($coins as $coin) else echo ' '; if($coin->block_height < $coin->target_height) { - $percent = round($coin->block_height*100/$coin->target_height, 2); - echo '
'.$percent.'%'; + $percent = round($coin->block_height*100/$coin->target_height, 1); + echo '
'.$percent.'%'; } echo ""; diff --git a/web/yaamp/modules/site/coin_console.php b/web/yaamp/modules/site/coin_console.php index 638fcf2..7e4518b 100644 --- a/web/yaamp/modules/site/coin_console.php +++ b/web/yaamp/modules/site/coin_console.php @@ -128,7 +128,10 @@ if (!empty($query)) try { if ($param === 'true' || $param === 'false') { $param = $param === 'true' ? true : false; } - else $param = (is_numeric($param)) ? 0 + $param : trim($param,'"'); + else if (strpos($param, '0x') === 0) + $param = "$param"; // eth hex crap + else + $param = (is_numeric($param)) ? 0 + $param : trim($param,'"'); $p[] = $param; } @@ -157,6 +160,9 @@ if (!empty($query)) try { case 7: $result = $remote->$command($p[0], $p[1], $p[2], $p[3], $p[4], $p[5], $p[6]); break; + case 8: + $result = $remote->$command($p[0], $p[1], $p[2], $p[3], $p[4], $p[5], $p[6], $p[7]); + break; default: $result = 'error: too much parameters'; }