35 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY 36 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "daemon" 43 ,
const boost::optional<tools::login>& login
48 : m_executor(
ip,
port, login, ssl_options, is_rpc, rpc_server)
55 std::cout <<
"use: print_pl [white] [gray] [<limit>]" << std::endl;
62 for (
size_t i = 0; i < args.size(); ++i)
64 if (args[i] ==
"white")
68 else if (args[i] ==
"gray")
74 std::cout <<
"unexpected argument: " << args[i] << std::endl;
79 const bool print_both = !white && !gray;
80 return m_executor.
print_peer_list(white | print_both, gray | print_both, limit);
85 if (!args.empty())
return false;
92 if (!args.empty())
return false;
99 if (!args.empty())
return false;
106 if (!args.empty())
return false;
113 if (!args.empty())
return false;
120 if (!args.empty())
return false;
127 if (!args.empty())
return false;
134 if (!args.empty())
return false;
143 std::cout <<
"need block index parameter" << std::endl;
150 std::cout <<
"wrong starter block index parameter" << std::endl;
155 std::cout <<
"wrong end block index parameter" << std::endl;
166 std::cout <<
"use: set_log [<log_level_number_0-4> | <categories>]" << std::endl;
180 std::cout <<
"wrong number range, use: set_log <log_level_number_0-4>" << std::endl;
193 if (!args.empty())
return false;
200 bool include_hex =
false;
203 for (
unsigned int i = 1; i < args.size(); ++i) {
204 if (args[i] ==
"+hex")
208 std::cout <<
"unexpected argument: " << args[i] << std::endl;
214 std::cout <<
"expected: print_block (<block_hash> | <block_height>) [+hex]" << std::endl;
224 catch (
const boost::bad_lexical_cast&)
238 bool include_hex =
false;
239 bool include_json =
false;
242 for (
unsigned int i = 1; i < args.size(); ++i) {
243 if (args[i] ==
"+hex")
245 else if (args[i] ==
"+json")
249 std::cout <<
"unexpected argument: " << args[i] << std::endl;
255 std::cout <<
"expected: print_tx <transaction_hash> [+hex] [+json]" << std::endl;
273 std::cout <<
"expected: is_key_image_spent <key_image>" << std::endl;
291 if (args.size() != 3) {
292 std::cout <<
"expected: is_public_output_spent <tx hash> <relative output index> <amount without decimal period, eg 0.01 should be 1>" << std::endl;
297 const std::string &relative_output_index_str = args[1];
303 std::cout <<
"Invalid transaction hash: " << tx_hash_str << std::endl;
310 std::cout <<
"Invalid relative output index: " << relative_output_index_str << std::endl;
317 std::cout <<
"Invalid amount: " << amount_str << std::endl;
334 if (!args.empty())
return false;
341 if (!args.empty())
return false;
348 if (!args.empty())
return false;
357 std::cout <<
"Please specify a wallet address to mine for: start_mining <addr> [<threads>|auto]" << std::endl;
371 [](
const std::string &url,
const std::vector<std::string> &addresses,
bool dnssec_valid){
return addresses[0];});
378 std::cout <<
"target account address has wrong format" << std::endl;
402 if (
info.is_subaddress)
408 std::cout <<
"Mining to a " << (nettype ==
cryptonote::TESTNET ?
"testnet" :
"stagenet") <<
" address, make sure this is intentional!" << std::endl;
410 bool do_background_mining =
false;
411 bool ignore_battery =
false;
421 ignore_battery =
true;
433 do_background_mining =
true;
443 if (args[1] ==
"auto" || args[1] ==
"autodetect")
450 threads_count = (ok && 0 < threads_count) ? threads_count : 1;
454 m_executor.
start_mining(
info.address, threads_count, nettype, do_background_mining, ignore_battery);
461 if (!args.empty())
return false;
473 if (!args.empty())
return false;
480 if (!args.empty())
return false;
487 if(args.size()>1)
return false;
493 limit = std::stoll(args[0]);
495 catch(
const std::exception& ex) {
496 std::cout <<
"failed to parse argument" << std::endl;
500 return m_executor.
set_limit(limit, limit);
505 if(args.size()>1)
return false;
511 limit = std::stoll(args[0]);
513 catch(
const std::exception& ex) {
514 std::cout <<
"failed to parse argument" << std::endl;
523 if(args.size()>1)
return false;
529 limit = std::stoll(args[0]);
531 catch(
const std::exception& ex) {
532 std::cout <<
"failed to parse argument" << std::endl;
541 if (args.empty())
return false;
545 limit = std::stoi(args[0]);
548 catch(
const std::exception& ex) {
549 _erro(
"stoi exception");
558 if (args.empty())
return false;
562 limit = std::stoi(args[0]);
565 catch(
const std::exception& ex) {
566 _erro(
"stoi exception");
575 if (!args.empty())
return false;
581 if (!args.empty())
return false;
588 if (args.size() == 0) {
591 else if (args.size() == 1) {
595 catch(
const std::exception& ex) {
598 if (version <= 0 || version > 255)
609 if (!args.empty())
return false;
615 if (args.size() != 1 && args.size() != 2)
return false;
623 seconds = std::numeric_limits<time_t>::max();
626 seconds = std::stoi(args[1]);
629 catch (
const std::exception &e)
638 return m_executor.
ban(
ip, seconds);
643 if (args.size() != 1)
return false;
650 if (args.size() > 1)
return false;
653 if (args.size() == 1)
658 std::cout <<
"failed to parse tx id" << std::endl;
668 std::vector<uint64_t> amounts;
673 for (
size_t n = 0; n < args.size(); ++n)
675 if (args[n][0] ==
'@')
677 amounts.push_back(boost::lexical_cast<uint64_t>(args[n].c_str() + 1));
681 min_count = boost::lexical_cast<
uint64_t>(args[n]);
686 max_count = boost::lexical_cast<
uint64_t>(args[n]);
691 std::cout <<
"Invalid syntax: more than two non-amount parameters" << std::endl;
702 std::cout <<
"need block height parameter" << std::endl;
709 std::cout <<
"wrong starter block height parameter" << std::endl;
714 std::cout <<
"wrong count parameter" << std::endl;
725 std::cout <<
"usage: alt_chain_info [block_hash]" << std::endl;
729 return m_executor.
alt_chain_info(args.size() == 1 ? args[0] :
"");
736 std::cout <<
"Exactly one parameter is needed" << std::endl;
743 std::cout <<
"wrong number of blocks" << std::endl;
754 std::cout <<
"Exactly one parameter is needed: check, download, or update" << std::endl;
758 return m_executor.
update(args.front());
763 if (args.size() != 1)
return false;
769 std::cout <<
"failed to parse tx id" << std::endl;
778 if (args.size() != 0)
return false;
785 if (args.size() != 1)
787 std::cout <<
"Exactly one parameter is needed" << std::endl;
796 std::cout <<
"number of blocks must be greater than 0" << std::endl;
801 catch (
const boost::bad_lexical_cast&)
803 std::cout <<
"number of blocks must be a number greater than 0" << std::endl;
816 if (args.size() > 1)
return false;
818 if (args.empty() || args[0] !=
"confirm")
820 std::cout <<
"Warning: pruning from within electroneumd will not shrink the database file size." << std::endl;
821 std::cout <<
"Instead, parts of the file will be marked as free, so the file will not grow" << std::endl;
822 std::cout <<
"until that newly free space is used up. If you want a smaller file size now," << std::endl;
823 std::cout <<
"exit electroneumd and run electroneum-blockchain-prune (you will temporarily need more" << std::endl;
824 std::cout <<
"disk space for the database conversion though). If you are OK with the database" << std::endl;
825 std::cout <<
"file keeping the same size, re-run this command with the \"confirm\" parameter." << std::endl;
839 if(args.size() != 1)
return false;
843 bool is_validator_key_valid = std::count_if(
key.begin(),
key.end(), [](
int c) {
return !std::isxdigit(c);}) == 0;
844 if(!is_validator_key_valid ||
key.size() != 64) {
845 std::cout <<
"Failed to parse validator key (wrong format)." << std::endl;
854 if(args.size() != 0)
return false;
861 if(args.size() != 2)
return false;
bool output_histogram(const std::vector< uint64_t > &amounts, uint64_t min_count, uint64_t max_count)
const char *const ELECTRONEUM_RELEASE_NAME
bool update(const std::string &command)
bool print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index)
bool start_mining(const std::vector< std::string > &args)
bool stop_save_graph(const std::vector< std::string > &args)
bool is_no(const std::string &str)
bool relay_tx(const std::string &txid)
bool unban(const std::string &ip)
bool show_status(const std::vector< std::string > &args)
bool print_transaction_pool_long(const std::vector< std::string > &args)
bool show_bans(const std::vector< std::string > &args)
bool flush_txpool(const std::vector< std::string > &args)
bool print_connections(const std::vector< std::string > &args)
bool set_log_categories(const std::string &categories)
bool start_mining(cryptonote::account_public_address address, uint64_t num_threads, cryptonote::network_type nettype, bool do_background_mining=false, bool ignore_battery=false)
bool hide_hash_rate(const std::vector< std::string > &args)
bool print_transaction_pool_stats(const std::vector< std::string > &args)
bool print_transaction_pool_short(const std::vector< std::string > &args)
bool check_blockchain_pruning()
bool set_log_level(int8_t level)
bool is_yes(const std::string &str)
bool unban(const std::vector< std::string > &args)
bool print_block(const std::vector< std::string > &args)
bool set_limit_up(const std::vector< std::string > &args)
bool set_limit(int64_t limit_down, int64_t limit_up)
bool print_transaction(const std::vector< std::string > &args)
bool sign_message(const std::vector< std::string > &args)
bool set_validator_key(const std::string &key)
bool in_peers(uint64_t limit)
bool print_blockchain_dynamic_stats(uint64_t nblocks)
bool print_net_stats(const std::vector< std::string > &args)
bool sign_message(const std::string privateKey, const std::string message)
bool stop_daemon(const std::vector< std::string > &args)
bool hard_fork_info(uint8_t version)
bool stop_mining(const std::vector< std::string > &args)
bool version(const std::vector< std::string > &args)
bool print_coinbase_tx_sum(uint64_t height, uint64_t count)
bool out_peers(uint64_t limit)
const char *const ELECTRONEUM_VERSION_FULL
mdb_size_t count(MDB_cursor *cur)
bool print_transaction_pool_long()
bool hard_fork_info(const std::vector< std::string > &args)
bool pop_blocks(uint64_t num_blocks)
bool relay_tx(const std::vector< std::string > &args)
bool set_validator_key(const std::vector< std::string > &args)
bool ban(const std::vector< std::string > &args)
bool print_coinbase_tx_sum(const std::vector< std::string > &args)
bool print_status(const std::vector< std::string > &args)
unsigned __int64 uint64_t
bool print_transaction_pool_short()
bool output_histogram(const std::vector< std::string > &args)
bool set_log_level(const std::vector< std::string > &args)
bool ban(const std::string &ip, time_t seconds)
bool generate_ed25519_keypair(const std::vector< std::string > &args)
bool print_peer_list_stats(const std::vector< std::string > &args)
bool set_limit_down(const std::vector< std::string > &args)
bool is_public_output_spent(const std::vector< std::string > &args)
boost::endian::big_uint32_t ip
boost::endian::big_uint16_t port
bool print_block_by_hash(crypto::hash block_hash, bool include_hex)
bool show_difficulty(const std::vector< std::string > &args)
bool update(const std::vector< std::string > &args)
bool print_peer_list_stats()
bool alt_chain_info(const std::vector< std::string > &args)
bool print_blockchain_info(const std::vector< std::string > &args)
bool in_peers(const std::vector< std::string > &args)
bool show_hash_rate(const std::vector< std::string > &args)
bool print_transaction_pool_stats()
void * memcpy(void *a, const void *b, size_t c)
bool pop_blocks(const std::vector< std::string > &args)
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
bool print_peer_list(const std::vector< std::string > &args)
bool is_key_image_spent(const crypto::key_image &ki)
bool check_blockchain_pruning(const std::vector< std::string > &args)
bool is_public_output_spent(const cryptonote::txin_to_key_public &txin)
bool flush_txpool(const std::string &txid)
bool prune_blockchain(const std::vector< std::string > &args)
bool set_limit(const std::vector< std::string > &args)
bool print_peer_list(bool white=true, bool gray=true, size_t limit=0)
bool parse_hash256(const std::string &str_hash, crypto::hash &hash)
bool generate_ed25519_keypair()
bool mining_status(const std::vector< std::string > &args)
bool sync_info(const std::vector< std::string > &args)
bool start_save_graph(const std::vector< std::string > &args)
bool print_blockchain_dynamic_stats(const std::vector< std::string > &args)
bool out_peers(const std::vector< std::string > &args)
bool alt_chain_info(const std::string &tip)
bool print_block_by_height(uint64_t height, bool include_hex)
bool is_key_image_spent(const std::vector< std::string > &args)
bool save_blockchain(const std::vector< std::string > &args)
t_command_parser_executor(uint32_t ip, uint16_t port, const boost::optional< tools::login > &login, const epee::net_utils::ssl_options_t &ssl_options, bool is_rpc, cryptonote::core_rpc_server *rpc_server=NULL)
bool print_height(const std::vector< std::string > &args)
bool print_transaction(crypto::hash transaction_hash, bool include_hex, bool include_json)