Monero
daemon_messages.h
Go to the documentation of this file.
1 // Copyright (c) 2016-2022, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 #pragma once
30 
31 #include <rapidjson/writer.h>
32 #include <unordered_map>
33 #include <vector>
34 
35 #include "byte_stream.h"
36 #include "message.h"
39 #include "rpc/daemon_rpc_version.h"
41 
42 #define BEGIN_RPC_MESSAGE_CLASS(classname) \
43 class classname \
44 { \
45  public:
46 
47 #define BEGIN_RPC_MESSAGE_REQUEST \
48  class Request final : public Message \
49  { \
50  public: \
51  Request() { } \
52  ~Request() { } \
53  void doToJson(rapidjson::Writer<epee::byte_stream>& dest) const override final; \
54  void fromJson(const rapidjson::Value& val) override final;
55 
56 #define BEGIN_RPC_MESSAGE_RESPONSE \
57  class Response final : public Message \
58  { \
59  public: \
60  Response() { } \
61  ~Response() { } \
62  void doToJson(rapidjson::Writer<epee::byte_stream>& dest) const override final; \
63  void fromJson(const rapidjson::Value& val) override final;
64 
65 #define END_RPC_MESSAGE_REQUEST };
66 #define END_RPC_MESSAGE_RESPONSE };
67 #define END_RPC_MESSAGE_CLASS };
68 
69 // NOTE: when using a type with multiple template parameters,
70 // replace any comma in the template specifier with the macro
71 // above, or the preprocessor will eat the comma in a bad way.
72 #define RPC_MESSAGE_MEMBER(type, name) type name = {}
73 
74 
75 namespace cryptonote
76 {
77 
78 namespace rpc
79 {
80 
81 BEGIN_RPC_MESSAGE_CLASS(GetHeight);
88 
89 
90 BEGIN_RPC_MESSAGE_CLASS(GetBlocksFast);
92  RPC_MESSAGE_MEMBER(std::list<crypto::hash>, block_ids);
93  RPC_MESSAGE_MEMBER(uint64_t, start_height);
97  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_with_transactions>, blocks);
98  RPC_MESSAGE_MEMBER(uint64_t, start_height);
99  RPC_MESSAGE_MEMBER(uint64_t, current_height);
100  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_output_indices>, output_indices);
101  RPC_MESSAGE_MEMBER(uint64_t, max_block_count);
104 
105 
106 BEGIN_RPC_MESSAGE_CLASS(GetHashesFast);
108  RPC_MESSAGE_MEMBER(std::list<crypto::hash>, known_hashes);
109  RPC_MESSAGE_MEMBER(uint64_t, start_height);
112  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, hashes);
113  RPC_MESSAGE_MEMBER(uint64_t, start_height);
114  RPC_MESSAGE_MEMBER(uint64_t, current_height);
117 
118 
119 BEGIN_RPC_MESSAGE_CLASS(GetTransactions);
121  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, tx_hashes);
124  using txes_map = std::unordered_map<crypto::hash, transaction_info>;
126  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, missed_hashes);
129 
130 
131 BEGIN_RPC_MESSAGE_CLASS(KeyImagesSpent);
132  enum STATUS {
133  UNSPENT = 0,
136  };
138  RPC_MESSAGE_MEMBER(std::vector<crypto::key_image>, key_images);
141  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, spent_status);
144 
145 
146 BEGIN_RPC_MESSAGE_CLASS(GetTxGlobalOutputIndices);
151  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, output_indices);
154 
155 
156 BEGIN_RPC_MESSAGE_CLASS(GetRandomOutputsForAmounts);
158  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
162  RPC_MESSAGE_MEMBER(std::vector<amount_with_random_outputs>, amounts_with_outputs);
165 
166 BEGIN_RPC_MESSAGE_CLASS(SendRawTx);
169  RPC_MESSAGE_MEMBER(bool, relay);
172  RPC_MESSAGE_MEMBER(bool, relayed);
175 
176 BEGIN_RPC_MESSAGE_CLASS(SendRawTxHex);
178  RPC_MESSAGE_MEMBER(std::string, tx_as_hex);
179  RPC_MESSAGE_MEMBER(bool, relay);
183 
184 BEGIN_RPC_MESSAGE_CLASS(StartMining);
186  RPC_MESSAGE_MEMBER(std::string, miner_address);
187  RPC_MESSAGE_MEMBER(uint64_t, threads_count);
188  RPC_MESSAGE_MEMBER(bool, do_background_mining);
189  RPC_MESSAGE_MEMBER(bool, ignore_battery);
194 
195 BEGIN_RPC_MESSAGE_CLASS(GetInfo);
202 
203 BEGIN_RPC_MESSAGE_CLASS(StopMining);
209 
210 BEGIN_RPC_MESSAGE_CLASS(MiningStatus);
214  RPC_MESSAGE_MEMBER(bool, active);
216  RPC_MESSAGE_MEMBER(uint64_t, threads_count);
218  RPC_MESSAGE_MEMBER(bool, is_background_mining_enabled);
221 
228 
229 BEGIN_RPC_MESSAGE_CLASS(GetBlockHash);
231  RPC_MESSAGE_MEMBER(uint64_t, height);
237 
238 BEGIN_RPC_MESSAGE_CLASS(GetBlockTemplate);
244 
245 BEGIN_RPC_MESSAGE_CLASS(SubmitBlock);
251 
252 BEGIN_RPC_MESSAGE_CLASS(GetLastBlockHeader);
259 
260 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeaderByHash);
268 
269 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeaderByHeight);
271  RPC_MESSAGE_MEMBER(uint64_t, height);
277 
278 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeadersByHeight);
280  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, heights);
283  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::BlockHeaderResponse>, headers);
286 
287 BEGIN_RPC_MESSAGE_CLASS(GetBlock);
293 
294 BEGIN_RPC_MESSAGE_CLASS(GetPeerList);
298  RPC_MESSAGE_MEMBER(std::vector<peer>, white_list);
299  RPC_MESSAGE_MEMBER(std::vector<peer>, gray_list);
302 
303 BEGIN_RPC_MESSAGE_CLASS(SetLogHashRate);
309 
310 BEGIN_RPC_MESSAGE_CLASS(SetLogLevel);
312  RPC_MESSAGE_MEMBER(int8_t, level);
317 
318 BEGIN_RPC_MESSAGE_CLASS(GetTransactionPool);
322  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::tx_in_pool>, transactions);
326 
327 BEGIN_RPC_MESSAGE_CLASS(GetConnections);
333 
334 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeadersRange);
340 
341 BEGIN_RPC_MESSAGE_CLASS(StopDaemon);
347 
348 BEGIN_RPC_MESSAGE_CLASS(StartSaveGraph);
354 
355 BEGIN_RPC_MESSAGE_CLASS(StopSaveGraph);
361 
362 BEGIN_RPC_MESSAGE_CLASS(HardForkInfo);
370 
371 BEGIN_RPC_MESSAGE_CLASS(GetBans);
377 
378 BEGIN_RPC_MESSAGE_CLASS(SetBans);
384 
385 BEGIN_RPC_MESSAGE_CLASS(FlushTransactionPool);
391 
392 BEGIN_RPC_MESSAGE_CLASS(GetOutputHistogram);
394  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
395  RPC_MESSAGE_MEMBER(uint64_t, min_count);
396  RPC_MESSAGE_MEMBER(uint64_t, max_count);
397  RPC_MESSAGE_MEMBER(bool, unlocked);
398  RPC_MESSAGE_MEMBER(uint64_t, recent_cutoff);
401  RPC_MESSAGE_MEMBER(std::vector<output_amount_count>, histogram);
404 
405 BEGIN_RPC_MESSAGE_CLASS(GetOutputKeys);
407  RPC_MESSAGE_MEMBER(std::vector<output_amount_and_index>, outputs);
410  RPC_MESSAGE_MEMBER(std::vector<output_key_mask_unlocked>, keys);
413 
414 BEGIN_RPC_MESSAGE_CLASS(GetRPCVersion);
421 
422 BEGIN_RPC_MESSAGE_CLASS(GetFeeEstimate);
424  RPC_MESSAGE_MEMBER(uint64_t, num_grace_blocks);
427  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, fees);
428  RPC_MESSAGE_MEMBER(uint64_t, estimated_base_fee);
429  RPC_MESSAGE_MEMBER(uint64_t, fee_mask);
430  RPC_MESSAGE_MEMBER(uint32_t, size_scale);
431  RPC_MESSAGE_MEMBER(uint8_t, hard_fork_version);
434 
435 BEGIN_RPC_MESSAGE_CLASS(GetOutputDistribution);
437  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
438  RPC_MESSAGE_MEMBER(uint64_t, from_height);
439  RPC_MESSAGE_MEMBER(uint64_t, to_height);
440  RPC_MESSAGE_MEMBER(bool, cumulative);
443  RPC_MESSAGE_MEMBER(std::vector<output_distribution>, distributions);
446 
447 } // namespace rpc
448 
449 } // namespace cryptonote
std::unordered_map< crypto::hash, transaction_info > txes_map
Definition: daemon_messages.h:124
int * count
Definition: gmock_stress_test.cc:176
SendRawTx::Response Response
Definition: daemon_messages.h:181
::std::string string
Definition: gtest-port.h:1097
END_RPC_MESSAGE_REQUEST
Definition: daemon_messages.h:83
Definition: message_data_structs.h:175
std::tuple< uint64_t, uint64_t, std::vector< tools::wallet2::transfer_details > > outputs
Definition: cold-outputs.cpp:53
Definition: daemon_messages.h:133
Definition: blocks.cpp:12
unsigned char uint8_t
Definition: stdint.h:124
struct hash_func hashes[]
Definition: daemon_messages.h:135
std::unordered_map< crypto::key_image, std::vector< crypto::hash > > key_images_with_tx_hashes
Definition: message_data_structs.h:107
Definition: daemon_messages.h:134
Definition: message_data_structs.h:160
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:44
BEGIN_RPC_MESSAGE_RESPONSE
Definition: daemon_messages.h:84
END_RPC_MESSAGE_RESPONSE
Definition: daemon_messages.h:86
Definition: message_data_structs.h:130
rpc
Definition: console.py:53
unsigned int uint32_t
Definition: stdint.h:126
END_RPC_MESSAGE_CLASS
Definition: daemon_messages.h:87
BEGIN_RPC_MESSAGE_CLASS(GetHeight)
unsigned __int64 uint64_t
Definition: stdint.h:136
signed char int8_t
Definition: stdint.h:121
RPC_MESSAGE_MEMBER(uint64_t, height)
static MDB_envinfo info
Definition: mdb_load.c:37
version
Supported socks variants.
Definition: socks.h:57
STATUS
Definition: daemon_messages.h:132
BEGIN_RPC_MESSAGE_REQUEST
Definition: daemon_messages.h:82
uint32_t address
Definition: getifaddr.c:269
Definition: minissdpd.c:66
static void prune(MDB_env *env0, MDB_env *env1)
Definition: blockchain_prune.cpp:249
cryptonote::transaction tx
Definition: transaction.cpp:40
epee::byte_slice active
Definition: levin_notify.cpp:257
Definition: speed.py:1
static boost::multiprecision::uint128_t fees
Definition: blockchain_stats.cpp:58
POD_CLASS hash
Definition: hash.h:49
Definition: cryptonote_basic.h:204