From fcbf51eca675b361a950c50b265618d5e365a76b Mon Sep 17 00:00:00 2001 From: SergiySW Date: Tue, 18 Jul 2017 22:09:52 +0300 Subject: [PATCH] RPC receive_minimum & wallet_work_get require enabled control --- rai/node/rpc.cpp | 56 ++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index f384ff9f..8eed8c97 100755 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -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 ("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 ("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"); } }