Monero C++ Library
Loading...
Searching...
No Matches
monero_daemon_rpc_model.h
1
54#pragma once
55
56#include "common/monero_rpc_connection.h"
57
61namespace monero {
62
66 struct monero_rpc_ban : public monero_ban {
67 monero_rpc_ban(const std::shared_ptr<monero_ban> &ban);
68
69 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
70 };
71
72 // ------------------------------ Binary Request ---------------------------------
73
77 struct monero_get_blocks_by_height_request : public monero_rpc_request {
78 std::vector<uint64_t> m_heights;
79
80 monero_get_blocks_by_height_request(uint64_t num_blocks);
81 monero_get_blocks_by_height_request(const std::vector<uint64_t>& heights): m_heights(heights) { m_method = "get_blocks_by_height.bin"; }
82
83 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
84 };
85
86 // ------------------------------ RPC Params ---------------------------------
87
88 struct monero_download_update_params : public serializable_struct {
89 boost::optional<std::string> m_command;
90 boost::optional<std::string> m_path;
91
92 monero_download_update_params(const std::string& command = "download", const std::string& path = "");
93
94 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
95 };
96
97 struct monero_submit_tx_params : public serializable_struct {
98 boost::optional<std::string> m_tx_hex;
99 boost::optional<bool> m_do_not_relay;
100 std::vector<std::string> m_tx_hashes;
101
102 monero_submit_tx_params(const std::vector<std::string>& tx_hashes): m_tx_hashes(tx_hashes) { }
103 monero_submit_tx_params(const std::string& tx_hex, bool do_not_relay): m_tx_hex(tx_hex), m_do_not_relay(do_not_relay) { }
104
105 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
106 };
107
109 boost::optional<int> m_in_peers;
110 boost::optional<int> m_out_peers;
111
112 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
113 };
114
115 struct monero_get_txs_params : public serializable_struct {
116 std::vector<std::string> m_tx_hashes;
117 boost::optional<bool> m_decode_as_json;
118 boost::optional<bool> m_prune;
119
120 monero_get_txs_params(const std::vector<std::string> &tx_hashes, bool prune, bool decode_as_json = true): m_tx_hashes(tx_hashes), m_prune(prune), m_decode_as_json(decode_as_json) { }
121
122 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
123 };
124
125 struct monero_is_key_image_spent_params : public serializable_struct {
126 std::vector<std::string> m_key_images;
127
128 monero_is_key_image_spent_params(const std::vector<std::string>& key_images): m_key_images(key_images) { }
129
130 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
131 };
132
133 // ------------------------------ JSON-RPC Params ---------------------------------
134
135 struct monero_start_mining_params : public serializable_struct {
136 boost::optional<std::string> m_miner_address;
137 boost::optional<uint64_t> m_num_threads;
138 boost::optional<bool> m_is_background;
139 boost::optional<bool> m_ignore_battery;
140
141 monero_start_mining_params(const boost::optional<std::string>& address, const boost::optional<uint64_t>& num_threads, const boost::optional<bool>& is_background, const boost::optional<bool>& ignore_battery): m_miner_address(address), m_num_threads(num_threads), m_is_background(is_background), m_ignore_battery(ignore_battery) { }
142 monero_start_mining_params(const boost::optional<uint64_t>& num_threads, const boost::optional<bool>& is_background, const boost::optional<bool>& ignore_battery): m_num_threads(num_threads), m_is_background(is_background), m_ignore_battery(ignore_battery) { }
143
144 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
145 };
146
147 struct monero_generate_blocks_params : public serializable_struct {
148 boost::optional<std::string> m_wallet_address;
149 boost::optional<uint64_t> m_num_blocks;
150 boost::optional<std::string> m_prev_block_hash;
151 boost::optional<uint32_t> m_starting_nonce;
152
153 monero_generate_blocks_params(const std::string& wallet_address, uint64_t num_blocks, const boost::optional<std::string>& prev_block_hash, const boost::optional<uint32_t>& starting_nonce): m_wallet_address(wallet_address), m_num_blocks(num_blocks), m_prev_block_hash(prev_block_hash), m_starting_nonce(starting_nonce) { }
154
155 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
156 };
157
158 struct monero_prune_blockchain_params : public serializable_struct {
159 boost::optional<bool> m_check;
160
161 monero_prune_blockchain_params(bool check = true): m_check(check) { }
162
163 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
164 };
165
166 struct monero_submit_blocks_params : public serializable_struct {
167 std::vector<std::string> m_block_blobs;
168
169 monero_submit_blocks_params(const std::vector<std::string>& block_blobs): m_block_blobs(block_blobs) { }
170
171 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
172 };
173
174 struct monero_get_block_params : public serializable_struct {
175 boost::optional<uint64_t> m_height;
176 boost::optional<std::string> m_hash;
177 boost::optional<bool> m_fill_pow_hash;
178 boost::optional<uint64_t> m_start_height;
179 boost::optional<uint64_t> m_end_height;
180 boost::optional<std::string> m_wallet_address;
181 boost::optional<int> m_reserve_size;
182
183 monero_get_block_params(uint64_t height, bool fill_pow_hash = false): m_height(height), m_fill_pow_hash(fill_pow_hash) { }
184 monero_get_block_params(const std::string& hash, bool fill_pow_hash = false): m_hash(hash), m_fill_pow_hash(fill_pow_hash) { }
185 monero_get_block_params(uint64_t start_height, uint64_t end_height): m_start_height(start_height), m_end_height(end_height) { }
186 monero_get_block_params(const std::string& wallet_address, const boost::optional<int>& reserve_size): m_wallet_address(wallet_address), m_reserve_size(reserve_size) { }
187
188 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
189 };
190
191 struct monero_get_block_hash_params : public serializable_struct {
192 boost::optional<uint64_t> m_height;
193
194 monero_get_block_hash_params(uint64_t height): m_height(height) { }
195
196 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
197 };
198
199 struct monero_get_miner_tx_sum_params : public serializable_struct {
200 boost::optional<uint64_t> m_height;
201 boost::optional<uint64_t> m_count;
202
203 monero_get_miner_tx_sum_params(uint64_t height, uint64_t count): m_height(height), m_count(count) { }
204
205 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
206 };
207
208 struct monero_get_fee_estimate_params : public serializable_struct {
209 boost::optional<uint64_t> m_grace_blocks;
210
211 monero_get_fee_estimate_params(uint64_t grace_blocks = 0): m_grace_blocks(grace_blocks) { }
212
213 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
214 };
215
216 struct monero_set_bans_params : public serializable_struct {
217 std::vector<std::shared_ptr<monero_rpc_ban>> m_bans;
218
219 monero_set_bans_params(const std::vector<std::shared_ptr<monero_ban>>& bans);
220
221 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
222 };
223
224 struct monero_get_output_histogram_params : public serializable_struct {
225 std::vector<uint64_t> m_amounts;
226 boost::optional<int> m_min_count;
227 boost::optional<int> m_max_count;
228 boost::optional<bool> m_is_unlocked;
229 boost::optional<int> m_recent_cutoff;
230
231 monero_get_output_histogram_params(const std::vector<uint64_t>& amounts, const boost::optional<int>& min_count, const boost::optional<int>& max_count, const boost::optional<bool>& is_unlocked, const boost::optional<int>& recent_cutoff) : m_amounts(amounts), m_min_count(min_count), m_max_count(max_count), m_is_unlocked(is_unlocked), m_recent_cutoff(recent_cutoff) { }
232
233 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
234 };
235
236 struct monero_get_output_distribution_params : public serializable_struct {
237 std::vector<uint64_t> m_amounts;
238 boost::optional<bool> m_cumulative;
239 boost::optional<bool> m_binary;
240 boost::optional<uint64_t> m_from_height;
241 boost::optional<uint64_t> m_to_height;
242
243 monero_get_output_distribution_params(const std::vector<uint64_t>& amounts, const boost::optional<bool>& cumulative, const boost::optional<uint64_t>& from_height, const boost::optional<uint64_t>& to_height) : m_amounts(amounts), m_cumulative(cumulative), m_from_height(from_height), m_to_height(to_height), m_binary(false) { }
244
245 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override;
246 };
247
248 // ------------------------------ JSON-RPC Response ---------------------------------
249
251 boost::optional<uint64_t> m_count;
252 boost::optional<uint64_t> m_height;
253 boost::optional<bool> m_untrusted;
254
255 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_get_block_result>& result);
256 };
257
258 // ------------------------------ RPC Deserialization ---------------------------------
259
260 void deserialize_version(const boost::property_tree::ptree& node, monero_version& version);
261 void deserialize_block_header(const boost::property_tree::ptree& node, const std::shared_ptr<monero_block_header>& header);
262 void deserialize_block_headers(const boost::property_tree::ptree& node, std::vector<std::shared_ptr<monero_block_header>>& headers);
263 void deserialize_block(const boost::property_tree::ptree& node, const std::shared_ptr<monero_block>& block, bool is_nested = false);
264 void deserialize_blocks(const boost::property_tree::ptree& node, const std::vector<uint64_t>& heights, std::vector<std::shared_ptr<monero_block>>& blocks);
265 void deserialize_alt_block_hashes(const boost::property_tree::ptree& node, std::vector<std::string>& block_hashes);
266 void deserialize_txs(const boost::property_tree::ptree& node, std::vector<std::shared_ptr<monero_tx>>& txs);
267 void deserialize_tx_hashes(const boost::property_tree::ptree& node, std::vector<std::string>& tx_hashes);
268 void deserialize_key_image_spent_status(const boost::property_tree::ptree& node, std::vector<monero_key_image_spent_status>& statuses);
269 void deserialize_alt_chains(const boost::property_tree::ptree& node, std::vector<std::shared_ptr<monero_alt_chain>>& alt_chains);
270 void deserialize_bans(const boost::property_tree::ptree& node, std::vector<std::shared_ptr<monero_ban>>& bans);
271 void deserialize_prune_result(const boost::property_tree::ptree& node, const std::shared_ptr<monero_prune_result>& result);
272 void deserialize_mining_status(const boost::property_tree::ptree& node, const std::shared_ptr<monero_mining_status>& status);
273 void deserialize_generate_blocks_result(const boost::property_tree::ptree& node, const std::shared_ptr<monero_generate_blocks_result>& result);
274 void deserialize_miner_tx_sum(const boost::property_tree::ptree& node, const std::shared_ptr<monero_miner_tx_sum>& sum);
275 void deserialize_block_template(const boost::property_tree::ptree& node, const std::shared_ptr<monero_block_template>& tmplt);
276 void deserialize_peers(const boost::property_tree::ptree& node, std::vector<std::shared_ptr<monero_peer>>& peers);
277 void deserialize_submit_tx_result(const boost::property_tree::ptree& node, const std::shared_ptr<monero_submit_tx_result>& result);
278 void deserialize_output_distribution_entries(const boost::property_tree::ptree& node, std::vector<std::shared_ptr<monero_output_distribution_entry>>& entries);
279 void deserialize_output_histogram_entries(const boost::property_tree::ptree& node, std::vector<std::shared_ptr<monero_output_histogram_entry>>& entries);
280 void deserialize_tx_pool_stats(const boost::property_tree::ptree& node, const std::shared_ptr<monero_tx_pool_stats>& stats);
281 void deserialize_update_check_result(const boost::property_tree::ptree& node, const std::shared_ptr<monero_daemon_update_check_result>& check);
282 void deserialize_update_download_result(const boost::property_tree::ptree& node, const std::shared_ptr<monero_daemon_update_download_result>& check);
283 void deserialize_fee_estimate(const boost::property_tree::ptree& node, const std::shared_ptr<monero_fee_estimate>& estimate);
284 void deserialize_daemon_info(const boost::property_tree::ptree& node, const std::shared_ptr<monero_daemon_info>& info);
285 void deserialize_daemon_sync_info(const boost::property_tree::ptree& node, const std::shared_ptr<monero_daemon_sync_info>& info);
286 void deserialize_hard_fork_info(const boost::property_tree::ptree& node, const std::shared_ptr<monero_hard_fork_info>& info);
287
288}
Definition monero_error.h:61
Definition monero_daemon_model.h:321
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:110
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:235
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:299
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:274
Definition monero_daemon_rpc_model.h:250
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:98
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:322
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:307
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:375
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:353
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:183
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:200
Definition monero_daemon_rpc_model.h:108
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:168
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:255
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:70
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:340
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:213
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:268
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const override
Definition monero_daemon_rpc_model.cpp:148
Definition monero_daemon_model.h:140
Definition monero_daemon_model.h:70