Monero
rpc_command_executor.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2014-2022, The Monero Project
10 //
11 // All rights reserved.
12 //
13 // Redistribution and use in source and binary forms, with or without modification, are
14 // permitted provided that the following conditions are met:
15 //
16 // 1. Redistributions of source code must retain the above copyright notice, this list of
17 // conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
20 // of conditions and the following disclaimer in the documentation and/or other
21 // materials provided with the distribution.
22 //
23 // 3. Neither the name of the copyright holder nor the names of its contributors may be
24 // used to endorse or promote products derived from this software without specific
25 // prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
29 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
30 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
35 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
38 
39 #pragma once
40 
41 #include <boost/optional/optional_fwd.hpp>
42 
43 #include "common/common_fwd.h"
44 #include "common/rpc_client.h"
46 #include "rpc/core_rpc_server.h"
47 
48 #undef MONERO_DEFAULT_LOG_CATEGORY
49 #define MONERO_DEFAULT_LOG_CATEGORY "daemon"
50 
51 namespace daemonize {
52 
54 private:
57  bool m_is_rpc;
58 
59 public:
61  uint32_t ip
62  , uint16_t port
63  , const boost::optional<tools::login>& user
64  , const epee::net_utils::ssl_options_t& ssl_options
65  , bool is_rpc = true
66  , cryptonote::core_rpc_server* rpc_server = NULL
67  );
68 
70 
71  bool print_peer_list(bool white = true, bool gray = true, size_t limit = 0, bool pruned_only = false, bool publicrpc_only = false);
72 
73  bool print_peer_list_stats();
74 
75  bool save_blockchain();
76 
77  bool show_hash_rate();
78 
79  bool hide_hash_rate();
80 
81  bool show_difficulty();
82 
83  bool show_status();
84 
85  bool print_connections();
86 
87  bool print_blockchain_info(int64_t start_block_index, uint64_t end_block_index);
88 
89  bool set_log_level(int8_t level);
90 
91  bool set_log_categories(const std::string &categories);
92 
93  bool print_height();
94 
95  bool print_block_by_hash(crypto::hash block_hash, bool include_hex);
96 
97  bool print_block_by_height(uint64_t height, bool include_hex);
98 
99  bool print_transaction(crypto::hash transaction_hash, bool include_metadata, bool include_hex, bool include_json);
100 
101  bool is_key_image_spent(const crypto::key_image &ki);
102 
104 
106 
108 
109  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);
110 
111  bool stop_mining();
112 
113  bool mining_status();
114 
115  bool stop_daemon();
116 
117  bool print_status();
118 
119  bool get_limit();
120 
121  bool get_limit_up();
122 
123  bool get_limit_down();
124 
125  bool set_limit(int64_t limit_down, int64_t limit_up);
126 
127  bool out_peers(bool set, uint32_t limit);
128 
129  bool in_peers(bool set, uint32_t limit);
130 
132 
133  bool print_bans();
134 
135  bool ban(const std::string &address, time_t seconds);
136 
137  bool unban(const std::string &address);
138 
139  bool banned(const std::string &address);
140 
141  bool flush_txpool(const std::string &txid);
142 
143  bool output_histogram(const std::vector<uint64_t> &amounts, uint64_t min_count, uint64_t max_count);
144 
146 
147  bool alt_chain_info(const std::string &tip, size_t above, uint64_t last_blocks);
148 
150 
151  bool update(const std::string &command);
152 
153  bool relay_tx(const std::string &txid);
154 
155  bool sync_info();
156 
158 
159  bool prune_blockchain();
160 
162 
163  bool print_net_stats();
164 
165  bool version();
166 
168  const std::string &address,
169  const std::string &username,
170  const std::string &password,
171  const std::string &proxy);
172 
173  bool rpc_payments();
174 
175  bool flush_cache(bool invalid_blocks);
176 };
177 
178 } // namespace daemonize
bool output_histogram(const std::vector< uint64_t > &amounts, uint64_t min_count, uint64_t max_count)
Definition: rpc_command_executor.cpp:1850
bool save_blockchain()
Definition: rpc_command_executor.cpp:268
bool m_is_rpc
Definition: rpc_command_executor.h:57
bool update(const std::string &command)
Definition: rpc_command_executor.cpp:2168
bool rpc_payments()
Definition: rpc_command_executor.cpp:2471
bool relay_tx(const std::string &txid)
Definition: rpc_command_executor.cpp:2215
~t_rpc_command_executor()
Definition: rpc_command_executor.cpp:181
Definition: net_ssl.h:76
bool print_connections()
Definition: rpc_command_executor.cpp:624
int * count
Definition: gmock_stress_test.cc:176
bool set_log_categories(const std::string &categories)
Definition: rpc_command_executor.cpp:853
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)
Definition: rpc_command_executor.cpp:1354
::std::string string
Definition: gtest-port.h:1097
bool set_bootstrap_daemon(const std::string &address, const std::string &username, const std::string &password, const std::string &proxy)
Definition: rpc_command_executor.cpp:2405
bool check_blockchain_pruning()
Definition: rpc_command_executor.cpp:2369
bool set_log_level(int8_t level)
Definition: rpc_command_executor.cpp:825
Definition: command_parser_executor.cpp:39
bool banned(const std::string &address)
Definition: rpc_command_executor.cpp:1787
uint64_t num_blocks(const std::vector< test_event_entry > &events)
Definition: chaingen.cpp:1220
bool mining_status()
Definition: rpc_command_executor.cpp:548
unsigned short uint16_t
Definition: stdint.h:125
bool alt_chain_info(const std::string &tip, size_t above, uint64_t last_blocks)
Definition: rpc_command_executor.cpp:1924
bool set_limit(int64_t limit_down, int64_t limit_up)
Definition: rpc_command_executor.cpp:1499
unsigned char uint8_t
Definition: stdint.h:124
bool version()
Definition: rpc_command_executor.cpp:2512
bool print_blockchain_dynamic_stats(uint64_t nblocks)
Definition: rpc_command_executor.cpp:2047
bool print_net_stats()
Definition: rpc_command_executor.cpp:690
bool print_peer_list(bool white=true, bool gray=true, size_t limit=0, bool pruned_only=false, bool publicrpc_only=false)
Definition: rpc_command_executor.cpp:189
bool print_transaction(crypto::hash transaction_hash, bool include_metadata, bool include_hex, bool include_json)
Definition: rpc_command_executor.cpp:976
bool print_blockchain_info(int64_t start_block_index, uint64_t end_block_index)
Definition: rpc_command_executor.cpp:752
bool hard_fork_info(uint8_t version)
Definition: rpc_command_executor.cpp:1652
bool print_coinbase_tx_sum(uint64_t height, uint64_t count)
Definition: rpc_command_executor.cpp:1889
bool print_height()
Definition: rpc_command_executor.cpp:881
bool stop_mining()
Definition: rpc_command_executor.cpp:1383
bool print_bans()
Definition: rpc_command_executor.cpp:1685
bool get_limit_up()
Definition: rpc_command_executor.cpp:1530
bool print_transaction_pool_long()
Definition: rpc_command_executor.cpp:1132
bool get_limit()
Definition: rpc_command_executor.cpp:1471
bool pop_blocks(uint64_t num_blocks)
Definition: rpc_command_executor.cpp:2313
unsigned int uint32_t
Definition: stdint.h:126
bool stop_daemon()
Definition: rpc_command_executor.cpp:1409
bool sync_info()
Definition: rpc_command_executor.cpp:2244
bool get_limit_down()
Definition: rpc_command_executor.cpp:1557
bool prune_blockchain()
Definition: rpc_command_executor.cpp:2340
unsigned __int64 uint64_t
Definition: stdint.h:136
bool print_transaction_pool_short()
Definition: rpc_command_executor.cpp:1218
Definition: rpc_client.h:44
signed char int8_t
Definition: stdint.h:121
boost::endian::big_uint32_t ip
Definition: socks.cpp:62
boost::endian::big_uint16_t port
Definition: socks.cpp:61
bool print_block_by_hash(crypto::hash block_hash, bool include_hex)
Definition: rpc_command_executor.cpp:908
Definition: rpc_command_executor.h:53
bool print_peer_list_stats()
Definition: rpc_command_executor.cpp:236
network_type
Definition: cryptonote_config.h:301
uint32_t address
Definition: getifaddr.c:269
Definition: cryptonote_basic.h:511
cryptonote::core_rpc_server * m_rpc_server
Definition: rpc_command_executor.h:56
POD_CLASS key_image
Definition: crypto.h:92
bool print_transaction_pool_stats()
Definition: rpc_command_executor.cpp:1269
bool out_peers(bool set, uint32_t limit)
Definition: rpc_command_executor.cpp:1584
bool print_status()
Definition: rpc_command_executor.cpp:1451
signed __int64 int64_t
Definition: stdint.h:135
bool show_difficulty()
Definition: rpc_command_executor.cpp:350
bool unban(const std::string &address)
Definition: rpc_command_executor.cpp:1754
bool is_key_image_spent(const crypto::key_image &ki)
Definition: rpc_command_executor.cpp:1096
Definition: core_rpc_server.h:55
bool hide_hash_rate()
Definition: rpc_command_executor.cpp:322
bool flush_txpool(const std::string &txid)
Definition: rpc_command_executor.cpp:1820
t_rpc_command_executor(uint32_t ip, uint16_t port, const boost::optional< tools::login > &user, const epee::net_utils::ssl_options_t &ssl_options, bool is_rpc=true, cryptonote::core_rpc_server *rpc_server=NULL)
Definition: rpc_command_executor.cpp:153
POD_CLASS hash
Definition: hash.h:49
bool show_hash_rate()
Definition: rpc_command_executor.cpp:295
bool flush_cache(bool invalid_blocks)
Definition: rpc_command_executor.cpp:2443
bool ban(const std::string &address, time_t seconds)
Definition: rpc_command_executor.cpp:1721
bool print_block_by_height(uint64_t height, bool include_hex)
Definition: rpc_command_executor.cpp:942
bool in_peers(bool set, uint32_t limit)
Definition: rpc_command_executor.cpp:1618
tools::t_rpc_client * m_rpc_client
Definition: rpc_command_executor.h:55
bool show_status()
Definition: rpc_command_executor.cpp:445