RPC receive_minimum & wallet_work_get require enabled control

This commit is contained in:
SergiySW 2017-07-18 22:09:52 +03:00
commit fcbf51eca6

View file

@ -1788,9 +1788,16 @@ void rai::rpc_handler::receive ()
void rai::rpc_handler::receive_minimum ()
{
boost::property_tree::ptree response_l;
response_l.put ("amount", node.config.receive_minimum.to_string_dec ());
response (response_l);
if (rpc.config.enable_control)
{
boost::property_tree::ptree response_l;
response_l.put ("amount", node.config.receive_minimum.to_string_dec ());
response (response_l);
}
else
{
error_response (response, "RPC control is disabled");
}
}
void rai::rpc_handler::receive_minimum_set ()
@ -2517,35 +2524,42 @@ void rai::rpc_handler::wallet_representative_set ()
void rai::rpc_handler::wallet_work_get ()
{
std::string wallet_text (request.get <std::string> ("wallet"));
rai::uint256_union wallet;
auto error (wallet.decode_hex (wallet_text));
if (!error)
if (rpc.config.enable_control)
{
auto existing (node.wallets.items.find (wallet));
if (existing != node.wallets.items.end ())
std::string wallet_text (request.get <std::string> ("wallet"));
rai::uint256_union wallet;
auto error (wallet.decode_hex (wallet_text));
if (!error)
{
boost::property_tree::ptree response_l;
boost::property_tree::ptree works;
rai::transaction transaction (node.store.environment, nullptr, false);
for (auto i (existing->second->store.begin (transaction)), n (existing->second->store.end ()); i != n; ++i)
auto existing (node.wallets.items.find (wallet));
if (existing != node.wallets.items.end ())
{
rai::account account(i->first);
uint64_t work (0);
auto error_work (existing->second->store.work_get (transaction, account, work));
works.put (account.to_account (), rai::to_string_hex (work));
boost::property_tree::ptree response_l;
boost::property_tree::ptree works;
rai::transaction transaction (node.store.environment, nullptr, false);
for (auto i (existing->second->store.begin (transaction)), n (existing->second->store.end ()); i != n; ++i)
{
rai::account account(i->first);
uint64_t work (0);
auto error_work (existing->second->store.work_get (transaction, account, work));
works.put (account.to_account (), rai::to_string_hex (work));
}
response_l.add_child ("works", works);
response (response_l);
}
else
{
error_response (response, "Wallet not found");
}
response_l.add_child ("works", works);
response (response_l);
}
else
{
error_response (response, "Wallet not found");
error_response (response, "Bad wallet number");
}
}
else
{
error_response (response, "Bad wallet number");
error_response (response, "RPC control is disabled");
}
}