Merge pull request #101 from SergiySW/rpc_extended
Porting several RPC from CLI
This commit is contained in:
commit
1d61de104f
2 changed files with 85 additions and 0 deletions
|
@ -220,6 +220,40 @@ void rai::rpc_handler::account_create ()
|
|||
}
|
||||
}
|
||||
|
||||
void rai::rpc_handler::account_get ()
|
||||
{
|
||||
std::string key_text (request.get <std::string> ("key"));
|
||||
rai::uint256_union pub;
|
||||
auto error (pub.decode_hex (key_text));
|
||||
if (!error)
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
response_l.put ("account", pub.to_account ());
|
||||
response (response_l);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_response (response, "Bad public key");
|
||||
}
|
||||
}
|
||||
|
||||
void rai::rpc_handler::account_key ()
|
||||
{
|
||||
std::string account_text (request.get <std::string> ("account"));
|
||||
rai::account account;
|
||||
auto error (account.decode_account (account_text));
|
||||
if (!error)
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
response_l.put ("key", account.to_string ());
|
||||
response (response_l);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_response (response, "Bad account number");
|
||||
}
|
||||
}
|
||||
|
||||
void rai::rpc_handler::account_list ()
|
||||
{
|
||||
std::string wallet_text (request.get <std::string> ("wallet"));
|
||||
|
@ -714,6 +748,37 @@ void rai::rpc_handler::keepalive ()
|
|||
}
|
||||
}
|
||||
|
||||
void rai::rpc_handler::key_create ()
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
rai::keypair pair;
|
||||
response_l.put ("private", pair.prv.data.to_string ());
|
||||
response_l.put ("public", pair.pub.to_string ());
|
||||
response_l.put ("account", pair.pub.to_account ());
|
||||
response (response_l);
|
||||
}
|
||||
|
||||
void rai::rpc_handler::key_expand ()
|
||||
{
|
||||
std::string key_text (request.get <std::string> ("key"));
|
||||
rai::uint256_union prv;
|
||||
auto error (prv.decode_hex (key_text));
|
||||
if (!error)
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
rai::uint256_union pub;
|
||||
ed25519_publickey (prv.bytes.data (), pub.bytes.data ());
|
||||
response_l.put ("private", prv.to_string ());
|
||||
response_l.put ("public", pub.to_string ());
|
||||
response_l.put ("account", pub.to_account ());
|
||||
response (response_l);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_response (response, "Bad private key");
|
||||
}
|
||||
}
|
||||
|
||||
void rai::rpc_handler::mrai_from_raw ()
|
||||
{
|
||||
std::string amount_text (request.get <std::string> ("amount"));
|
||||
|
@ -1733,6 +1798,14 @@ void rai::rpc_handler::process_request ()
|
|||
{
|
||||
account_create ();
|
||||
}
|
||||
else if (action == "account_get")
|
||||
{
|
||||
account_get ();
|
||||
}
|
||||
else if (action == "account_key")
|
||||
{
|
||||
account_key ();
|
||||
}
|
||||
else if (action == "account_list")
|
||||
{
|
||||
account_list ();
|
||||
|
@ -1793,6 +1866,14 @@ void rai::rpc_handler::process_request ()
|
|||
{
|
||||
keepalive ();
|
||||
}
|
||||
else if (action == "key_create")
|
||||
{
|
||||
key_create ();
|
||||
}
|
||||
else if (action == "key_expand")
|
||||
{
|
||||
key_expand ();
|
||||
}
|
||||
else if (action == "krai_from_raw")
|
||||
{
|
||||
krai_from_raw ();
|
||||
|
|
|
@ -90,6 +90,8 @@ public:
|
|||
void process_request ();
|
||||
void account_balance ();
|
||||
void account_create ();
|
||||
void account_get ();
|
||||
void account_key ();
|
||||
void account_list ();
|
||||
void account_move ();
|
||||
void account_representative ();
|
||||
|
@ -105,6 +107,8 @@ public:
|
|||
void frontier_count ();
|
||||
void history ();
|
||||
void keepalive ();
|
||||
void key_create ();
|
||||
void key_expand ();
|
||||
void krai_to_raw ();
|
||||
void krai_from_raw ();
|
||||
void mrai_to_raw ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue