diff --git a/easyraiblocks.php b/easyraiblocks.php index b8bda92..321d389 100644 --- a/easyraiblocks.php +++ b/easyraiblocks.php @@ -147,6 +147,8 @@ function __call( $method, $params ){ } $request = json_encode($request); + + echo ($request); // Build the cURL session $curl = curl_init("{$this->proto}://{$this->host}:{$this->port}/{$this->url}"); @@ -191,6 +193,8 @@ function __call( $method, $params ){ // Execute the request and decode to an array $this->raw_response = curl_exec( $curl ); + + echo($this->raw_response); $this->response = json_decode( $this->raw_response, TRUE ); // If the status is not 200, something is wrong diff --git a/easyrainode.php b/easyrainode.php index c1fd38d..60e0516 100644 --- a/easyrainode.php +++ b/easyrainode.php @@ -26,7 +26,8 @@ // Includes - include("easyraiblocks.php"); // Include RPC class + + include("easyraiblocks.php"); // Include RPC class include("easyraiext.php"); // Include extension class include("easyrainode_config.php"); // Include configuration file @@ -40,7 +41,7 @@ function americanu($number,$decimal){ function rb_call_method($method,$params = null){ - global $rb; global $dwallets; + global $rb; global $dwallets; global $daccounts; global $dkey; $args = array(); @@ -48,7 +49,11 @@ function rb_call_method($method,$params = null){ if($params != null){ + print_r($params); + echo "\n"; + + foreach( $params as $key=>$param ){ @@ -72,7 +77,7 @@ function rb_call_method($method,$params = null){ if (count($dwallets) > 0) { - echo "Preconfigured wallets:\n\n"; + echo "Preconfigured wallets (use first as default):\n\n"; foreach ($dwallets as $tag=>$wid) { @@ -80,17 +85,50 @@ function rb_call_method($method,$params = null){ } + + echo "\n"; + } + + echo $key."[". $dwallets[$dkey] ."] : "; + + } else + + if( $param == "account" ){ + + if (count($daccounts) > 0) { + + echo "Preconfigured accounts (use first as default):\n\n"; + + foreach ($daccounts as $tag=>$wid) { + + echo $tag." => ".$wid."\n"; + + } + echo "\n"; } + + echo $key."[". $daccounts[$dkey] ."] : "; - } + } else + + echo $key.": "; - echo $key.": "; + $line = stream_get_line( STDIN, 1024, PHP_EOL ); if ($param == "wallet") { + + + // ep use first as default + if (empty($line) && !empty($dwallets[$dkey]) ) { + + + $line = $dwallets[$dkey]; + + } else if (array_key_exists($line,$dwallets)) { @@ -100,7 +138,26 @@ function rb_call_method($method,$params = null){ $lastwallet = $line; - } + } else if ($param == "account") { + + + // ep use first as default + if (empty($line) && !empty($daccounts[$dkey]) ) { + + + $line = $daccounts[$dkey]; + + } else + + if (array_key_exists($line,$daccounts)) { + + $line = $daccounts[$line]; + + } + + $lastwallet = $line; + + } $args[$param] = $line; @@ -153,6 +210,8 @@ function rb_call_method($method,$params = null){ "wcs" => array("Wallet change seed","wallet_change_seed",array("Wallet"=>"wallet","Seed"=>"seed")), "wtb" => array("Wallet total balance","wallet_balance_total",array("Wallet"=>"wallet")), "wab" => array("Wallet accounts balances","wallet_balances",array("Wallet"=>"wallet")), + "wlc" => array("Wallet locked check", "wallet_locked", array("Wallet"=>"wallet")), + // Account "sep2" => array("Account","separator"), "ab" => array("Account balance","account_balance",array("Account"=>"account")), @@ -194,6 +253,11 @@ function rb_call_method($method,$params = null){ "re" => array("Representatives","representatives",null), "cub" => array("Clear unchecked blocks","unchecked_clear",null), "sn" => array("Stop node","stop",null), + "dk" => array("Deterministic Key","deterministic_key",array("Seed"=>"seed","Index"=>"index")), + "rb" => array("Retrieve block", "blocks_info", array("hash" => "hash")), + "rec" => array("Receive block", "receive", array("wallet" => "wallet", "account" => "account" , "block" => "block")), + + // Extension "sep4" => array("Extensions","separator"), "e_bws" => array("Wallets balances","raiblocks_summary_wallets",null), @@ -283,14 +347,35 @@ function rb_call_method($method,$params = null){ } - } + } elseif ( $param == "account" ){ + + if (count($daccounts) > 0) { + + echo "Preconfigured accounts:\n\n"; + + foreach ($daccounts as $tag=>$wid) { + + echo $tag." => ".$wid."\n"; + + } + + echo "\n"; + + } + } echo $key.": "; $line2 = stream_get_line( STDIN, 1024, PHP_EOL ); if ($param == "wallet") { - if (array_key_exists($line2,$dwallets)) { + + if (empty($line2) && !empty($dwallets[0]) ) { + + + $line2 = $dwallets[0]; + + } else if (array_key_exists($line2,$dwallets)) { $line2 = $dwallets[$line2]; @@ -298,7 +383,24 @@ function rb_call_method($method,$params = null){ $lastwallet = $line2; + } else if ($param == "account") { + + + if (empty($line2) && !empty($daccounts[0]) ) { + + + $line2 = $daccounts[0]; + + } else if (array_key_exists($line2,$daccounts)) { + + $line2 = $daccounts[$line2]; + + } + + $lastwallet = $line2; + } + $args[] = $line2; diff --git a/easyrainode_config.php b/easyrainode_config.php index 6a01dfd..7694b45 100644 --- a/easyrainode_config.php +++ b/easyrainode_config.php @@ -6,17 +6,30 @@ // Node connection parameters - DEFINE("RB_HOST","127.0.0.1"); // RaiBlocks node host + DEFINE("RB_HOST","139.162.231.197"); // RaiBlocks node host DEFINE("RB_PORT","7076"); // RaiBlocks node port DEFINE("RB_URL",null); // I don't know what this is for, just leave null + + error_reporting(E_ERROR | E_WARNING | E_PARSE); + // Other parameters $dwallets = array( // Default wallets, type the wallet tag to use the wallet ID when CLI ask to you - //"tag" => "wallet ID" + "fullnode" => "1711635F5292E79A74767FE4B48491CAD3454F8DFB4A543327BCA34029983F8E" ); + + $daccounts = array( // Default wallets, type the wallet tag to use the wallet ID when CLI ask to you + + "fullnode" => "xrb_1ztxehegbtkx5swheeh5domysiea9miwie3ap96o8dmcf7j14qmw4zcffemz" + + ); + + $dkey = "fullnode"; + + // Connection to node