diff options
Diffstat (limited to 'src/daemon/command_parser_executor.cpp')
-rw-r--r-- | src/daemon/command_parser_executor.cpp | 70 |
1 files changed, 47 insertions, 23 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 9e61e9acd..5307b2472 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -267,20 +267,18 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg return true; } - cryptonote::account_public_address adr; - bool has_payment_id; - crypto::hash8 payment_id; + cryptonote::address_parse_info info; bool testnet = false; - if(!cryptonote::get_account_integrated_address_from_str(adr, has_payment_id, payment_id, false, args.front())) + if(!cryptonote::get_account_address_from_str(info, false, args.front())) { - if(!cryptonote::get_account_integrated_address_from_str(adr, has_payment_id, payment_id, true, args.front())) + if(!cryptonote::get_account_address_from_str(info, true, args.front())) { bool dnssec_valid; std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec_valid, [](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid){return addresses[0];}); - if(!cryptonote::get_account_integrated_address_from_str(adr, has_payment_id, payment_id, false, address_str)) + if(!cryptonote::get_account_address_from_str(info, false, address_str)) { - if(!cryptonote::get_account_integrated_address_from_str(adr, has_payment_id, payment_id, true, address_str)) + if(!cryptonote::get_account_address_from_str(info, true, address_str)) { std::cout << "target account address has wrong format" << std::endl; return true; @@ -296,6 +294,11 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg testnet = true; } } + if (info.is_subaddress) + { + tools::fail_msg_writer() << "subaddress for mining reward is not yet supported!" << std::endl; + return true; + } if(testnet) std::cout << "Mining to a testnet address, make sure this is intentional!" << std::endl; uint64_t threads_count = 1; @@ -322,7 +325,7 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg threads_count = (ok && 0 < threads_count) ? threads_count : 1; } - m_executor.start_mining(adr, threads_count, testnet, do_background_mining, ignore_battery); + m_executor.start_mining(info.address, threads_count, testnet, do_background_mining, ignore_battery); return true; } @@ -358,7 +361,7 @@ bool t_command_parser_executor::set_limit(const std::vector<std::string>& args) try { limit = std::stoll(args[0]); } - catch(const std::invalid_argument& ex) { + catch(const std::exception& ex) { std::cout << "failed to parse argument" << std::endl; return false; } @@ -378,7 +381,7 @@ bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& arg try { limit = std::stoll(args[0]); } - catch(const std::invalid_argument& ex) { + catch(const std::exception& ex) { std::cout << "failed to parse argument" << std::endl; return false; } @@ -398,7 +401,7 @@ bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& a try { limit = std::stoll(args[0]); } - catch(const std::invalid_argument& ex) { + catch(const std::exception& ex) { std::cout << "failed to parse argument" << std::endl; return false; } @@ -417,7 +420,7 @@ bool t_command_parser_executor::out_peers(const std::vector<std::string>& args) limit = std::stoi(args[0]); } - catch(std::invalid_argument& ex) { + catch(std::exception& ex) { _erro("stoi exception"); return false; } @@ -447,7 +450,7 @@ bool t_command_parser_executor::hard_fork_info(const std::vector<std::string>& a try { version = std::stoi(args[0]); } - catch(std::invalid_argument& ex) { + catch(std::exception& ex) { return false; } if (version <= 0 || version > 255) @@ -472,7 +475,14 @@ bool t_command_parser_executor::ban(const std::vector<std::string>& args) time_t seconds = P2P_IP_BLOCKTIME; if (args.size() > 1) { - seconds = std::stoi(args[1]); + try + { + seconds = std::stoi(args[1]); + } + catch (const std::exception &e) + { + return false; + } if (seconds == 0) { return false; @@ -508,20 +518,34 @@ bool t_command_parser_executor::flush_txpool(const std::vector<std::string>& arg bool t_command_parser_executor::output_histogram(const std::vector<std::string>& args) { - if (args.size() > 2) return false; - + std::vector<uint64_t> amounts; uint64_t min_count = 3; uint64_t max_count = 0; + size_t n_raw = 0; - if (args.size() >= 1) - { - min_count = boost::lexical_cast<uint64_t>(args[0]); - } - if (args.size() >= 2) + for (size_t n = 0; n < args.size(); ++n) { - max_count = boost::lexical_cast<uint64_t>(args[1]); + if (args[n][0] == '@') + { + amounts.push_back(boost::lexical_cast<uint64_t>(args[n].c_str() + 1)); + } + else if (n_raw == 0) + { + min_count = boost::lexical_cast<uint64_t>(args[n]); + n_raw++; + } + else if (n_raw == 1) + { + max_count = boost::lexical_cast<uint64_t>(args[n]); + n_raw++; + } + else + { + std::cout << "Invalid syntax: more than two non-amount parameters" << std::endl; + return true; + } } - return m_executor.output_histogram(min_count, max_count); + return m_executor.output_histogram(amounts, min_count, max_count); } bool t_command_parser_executor::print_coinbase_tx_sum(const std::vector<std::string>& args) |