Monero
daemon_messages.h
Go to the documentation of this file.
1 // Copyright (c) 2016-2020, 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 
85  RPC_MESSAGE_MEMBER(uint64_t, height);
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);
103 
104 
105 BEGIN_RPC_MESSAGE_CLASS(GetHashesFast);
107  RPC_MESSAGE_MEMBER(std::list<crypto::hash>, known_hashes);
108  RPC_MESSAGE_MEMBER(uint64_t, start_height);
111  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, hashes);
112  RPC_MESSAGE_MEMBER(uint64_t, start_height);
113  RPC_MESSAGE_MEMBER(uint64_t, current_height);
116 
117 
118 BEGIN_RPC_MESSAGE_CLASS(GetTransactions);
120  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, tx_hashes);
123  using txes_map = std::unordered_map<crypto::hash, transaction_info>;
125  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, missed_hashes);
128 
129 
130 BEGIN_RPC_MESSAGE_CLASS(KeyImagesSpent);
131  enum STATUS {
132  UNSPENT = 0,
135  };
137  RPC_MESSAGE_MEMBER(std::vector<crypto::key_image>, key_images);
140  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, spent_status);
143 
144 
145 BEGIN_RPC_MESSAGE_CLASS(GetTxGlobalOutputIndices);
150  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, output_indices);
153 
154 
155 BEGIN_RPC_MESSAGE_CLASS(GetRandomOutputsForAmounts);
157  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
161  RPC_MESSAGE_MEMBER(std::vector<amount_with_random_outputs>, amounts_with_outputs);
164 
168  RPC_MESSAGE_MEMBER(bool, relay);
171  RPC_MESSAGE_MEMBER(bool, relayed);
174 
177  RPC_MESSAGE_MEMBER(std::string, tx_as_hex);
178  RPC_MESSAGE_MEMBER(bool, relay);
182 
185  RPC_MESSAGE_MEMBER(std::string, miner_address);
186  RPC_MESSAGE_MEMBER(uint64_t, threads_count);
187  RPC_MESSAGE_MEMBER(bool, do_background_mining);
188  RPC_MESSAGE_MEMBER(bool, ignore_battery);
193 
201 
208 
213  RPC_MESSAGE_MEMBER(bool, active);
214  RPC_MESSAGE_MEMBER(uint64_t, speed);
215  RPC_MESSAGE_MEMBER(uint64_t, threads_count);
216  RPC_MESSAGE_MEMBER(std::string, address);
217  RPC_MESSAGE_MEMBER(bool, is_background_mining_enabled);
220 
227 
230  RPC_MESSAGE_MEMBER(uint64_t, height);
236 
237 BEGIN_RPC_MESSAGE_CLASS(GetBlockTemplate);
243 
250 
251 BEGIN_RPC_MESSAGE_CLASS(GetLastBlockHeader);
258 
259 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeaderByHash);
267 
268 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeaderByHeight);
270  RPC_MESSAGE_MEMBER(uint64_t, height);
276 
277 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeadersByHeight);
279  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, heights);
282  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::BlockHeaderResponse>, headers);
285 
292 
297  RPC_MESSAGE_MEMBER(std::vector<peer>, white_list);
298  RPC_MESSAGE_MEMBER(std::vector<peer>, gray_list);
301 
302 BEGIN_RPC_MESSAGE_CLASS(SetLogHashRate);
308 
311  RPC_MESSAGE_MEMBER(int8_t, level);
316 
317 BEGIN_RPC_MESSAGE_CLASS(GetTransactionPool);
321  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::tx_in_pool>, transactions);
325 
326 BEGIN_RPC_MESSAGE_CLASS(GetConnections);
332 
333 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeadersRange);
339 
346 
347 BEGIN_RPC_MESSAGE_CLASS(StartSaveGraph);
353 
354 BEGIN_RPC_MESSAGE_CLASS(StopSaveGraph);
360 
369 
376 
383 
384 BEGIN_RPC_MESSAGE_CLASS(FlushTransactionPool);
390 
391 BEGIN_RPC_MESSAGE_CLASS(GetOutputHistogram);
393  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
394  RPC_MESSAGE_MEMBER(uint64_t, min_count);
395  RPC_MESSAGE_MEMBER(uint64_t, max_count);
396  RPC_MESSAGE_MEMBER(bool, unlocked);
397  RPC_MESSAGE_MEMBER(uint64_t, recent_cutoff);
400  RPC_MESSAGE_MEMBER(std::vector<output_amount_count>, histogram);
403 
404 BEGIN_RPC_MESSAGE_CLASS(GetOutputKeys);
406  RPC_MESSAGE_MEMBER(std::vector<output_amount_and_index>, outputs);
409  RPC_MESSAGE_MEMBER(std::vector<output_key_mask_unlocked>, keys);
412 
413 BEGIN_RPC_MESSAGE_CLASS(GetRPCVersion);
420 
421 BEGIN_RPC_MESSAGE_CLASS(GetFeeEstimate);
423  RPC_MESSAGE_MEMBER(uint64_t, num_grace_blocks);
426  RPC_MESSAGE_MEMBER(uint64_t, estimated_base_fee);
427  RPC_MESSAGE_MEMBER(uint64_t, fee_mask);
428  RPC_MESSAGE_MEMBER(uint32_t, size_scale);
429  RPC_MESSAGE_MEMBER(uint8_t, hard_fork_version);
432 
433 BEGIN_RPC_MESSAGE_CLASS(GetOutputDistribution);
435  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
436  RPC_MESSAGE_MEMBER(uint64_t, from_height);
437  RPC_MESSAGE_MEMBER(uint64_t, to_height);
438  RPC_MESSAGE_MEMBER(bool, cumulative);
441  RPC_MESSAGE_MEMBER(std::vector<output_distribution>, distributions);
444 
445 } // namespace rpc
446 
447 } // namespace cryptonote
static void prune(MDB_env *env0, MDB_env *env1)
Definition: blockchain_prune.cpp:246
Definition: cryptonote_basic.h:194
Definition: blocks.cpp:13
POD_CLASS hash
Definition: hash.h:48
END_RPC_MESSAGE_CLASS
Definition: daemon_messages.h:87
END_RPC_MESSAGE_REQUEST
Definition: daemon_messages.h:83
BEGIN_RPC_MESSAGE_RESPONSE
Definition: daemon_messages.h:84
SendRawTx::Response Response
Definition: daemon_messages.h:180
RPC_MESSAGE_MEMBER(uint64_t, height)
BEGIN_RPC_MESSAGE_REQUEST
Definition: daemon_messages.h:82
END_RPC_MESSAGE_RESPONSE
Definition: daemon_messages.h:86
std::unordered_map< crypto::key_image, std::vector< crypto::hash > > key_images_with_tx_hashes
Definition: message_data_structs.h:107
STATUS
Definition: daemon_messages.h:131
@ SPENT_IN_POOL
Definition: daemon_messages.h:134
@ SPENT_IN_BLOCKCHAIN
Definition: daemon_messages.h:133
@ UNSPENT
Definition: daemon_messages.h:132
BEGIN_RPC_MESSAGE_CLASS(GetHeight)
std::unordered_map< crypto::hash, transaction_info > txes_map
Definition: daemon_messages.h:123
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
mdb_size_t count(MDB_cursor *cur)
Definition: value_stream.cpp:39
version
Supported socks variants.
Definition: socks.h:58
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:90
Definition: message_data_structs.h:161
Definition: message_data_structs.h:176
Definition: message_data_structs.h:131