aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/command_parser_executor.cpp70
-rw-r--r--src/daemon/main.cpp6
-rw-r--r--src/daemon/rpc_command_executor.cpp5
-rw-r--r--src/daemon/rpc_command_executor.h2
4 files changed, 54 insertions, 29 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)
diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp
index acc23b9f9..5d548f410 100644
--- a/src/daemon/main.cpp
+++ b/src/daemon/main.cpp
@@ -61,7 +61,7 @@ int main(int argc, char const * argv[])
// TODO parse the debug options like set log level right here at start
- tools::sanitize_locale();
+ tools::on_startup();
epee::string_tools::set_module_name_and_folder(argv[0]);
@@ -205,13 +205,13 @@ int main(int argc, char const * argv[])
// absolute path
// relative path: relative to data_dir
bf::path log_file_path {data_dir / std::string(CRYPTONOTE_NAME ".log")};
- if (! vm["log-file"].defaulted())
+ if (!command_line::is_arg_defaulted(vm, daemon_args::arg_log_file))
log_file_path = command_line::get_arg(vm, daemon_args::arg_log_file);
log_file_path = bf::absolute(log_file_path, relative_path_base);
mlog_configure(log_file_path.string(), true, command_line::get_arg(vm, daemon_args::arg_max_log_file_size));
// Set log level
- if (!vm["log-level"].defaulted())
+ if (!command_line::is_arg_defaulted(vm, daemon_args::arg_log_level))
{
mlog_set_log(command_line::get_arg(vm, daemon_args::arg_log_level).c_str());
}
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index cf33ec644..2c11dcb31 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -1020,7 +1020,7 @@ bool t_rpc_command_executor::print_transaction_pool_stats() {
bool t_rpc_command_executor::start_mining(cryptonote::account_public_address address, uint64_t num_threads, bool testnet, bool do_background_mining, bool ignore_battery) {
cryptonote::COMMAND_RPC_START_MINING::request req;
cryptonote::COMMAND_RPC_START_MINING::response res;
- req.miner_address = cryptonote::get_account_address_as_str(testnet, address);
+ req.miner_address = cryptonote::get_account_address_as_str(testnet, false, address);
req.threads_count = num_threads;
req.do_background_mining = do_background_mining;
req.ignore_battery = ignore_battery;
@@ -1496,13 +1496,14 @@ bool t_rpc_command_executor::flush_txpool(const std::string &txid)
return true;
}
-bool t_rpc_command_executor::output_histogram(uint64_t min_count, uint64_t max_count)
+bool t_rpc_command_executor::output_histogram(const std::vector<uint64_t> &amounts, uint64_t min_count, uint64_t max_count)
{
cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request req;
cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response res;
std::string fail_message = "Unsuccessful";
epee::json_rpc::error error_resp;
+ req.amounts = amounts;
req.min_count = min_count;
req.max_count = max_count;
req.unlocked = false;
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index 26db18902..efe1ae56a 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -137,7 +137,7 @@ public:
bool flush_txpool(const std::string &txid);
- bool output_histogram(uint64_t min_count, uint64_t max_count);
+ bool output_histogram(const std::vector<uint64_t> &amounts, uint64_t min_count, uint64_t max_count);
bool print_coinbase_tx_sum(uint64_t height, uint64_t count);