Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

added two commands and added default wallet and account funtionality #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions easyraiblocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand Down Expand Up @@ -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
Expand Down
118 changes: 110 additions & 8 deletions easyrainode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -40,15 +41,19 @@ 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();

echo $method."\n";

if($params != null){

print_r($params);

echo "\n";



foreach( $params as $key=>$param ){

Expand All @@ -72,25 +77,58 @@ 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) {

echo $tag." => ".$wid."\n";

}


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)) {

Expand All @@ -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;

Expand Down Expand Up @@ -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")),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -283,22 +347,60 @@ 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];

}

$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;

Expand Down
17 changes: 15 additions & 2 deletions easyrainode_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down