Monero
daemon_messages.h
Go to the documentation of this file.
1 // Copyright (c) 2016-2018, 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 "message.h"
34 #include "rpc/daemon_rpc_version.h"
36 
37 #define BEGIN_RPC_MESSAGE_CLASS(classname) \
38 class classname \
39 { \
40  public: \
41  static const char* const name;
42 
43 #define BEGIN_RPC_MESSAGE_REQUEST \
44  class Request : public Message \
45  { \
46  public: \
47  Request() { } \
48  ~Request() { } \
49  rapidjson::Value toJson(rapidjson::Document& doc) const; \
50  void fromJson(rapidjson::Value& val);
51 
52 #define BEGIN_RPC_MESSAGE_RESPONSE \
53  class Response : public Message \
54  { \
55  public: \
56  Response() { } \
57  ~Response() { } \
58  rapidjson::Value toJson(rapidjson::Document& doc) const; \
59  void fromJson(rapidjson::Value& val);
60 
61 #define END_RPC_MESSAGE_REQUEST };
62 #define END_RPC_MESSAGE_RESPONSE };
63 #define END_RPC_MESSAGE_CLASS };
64 
65 #define COMMA() ,
66 
67 // NOTE: when using a type with multiple template parameters,
68 // replace any comma in the template specifier with the macro
69 // above, or the preprocessor will eat the comma in a bad way.
70 #define RPC_MESSAGE_MEMBER(type, name) type name;
71 
72 
73 namespace cryptonote
74 {
75 
76 namespace rpc
77 {
78 
79 BEGIN_RPC_MESSAGE_CLASS(GetHeight);
83  RPC_MESSAGE_MEMBER(uint64_t, height);
86 
87 
88 BEGIN_RPC_MESSAGE_CLASS(GetBlocksFast);
90  RPC_MESSAGE_MEMBER(std::list<crypto::hash>, block_ids);
91  RPC_MESSAGE_MEMBER(uint64_t, start_height);
92  RPC_MESSAGE_MEMBER(bool, prune);
95  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_with_transactions>, blocks);
96  RPC_MESSAGE_MEMBER(uint64_t, start_height);
97  RPC_MESSAGE_MEMBER(uint64_t, current_height);
98  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_output_indices>, output_indices);
101 
102 
103 BEGIN_RPC_MESSAGE_CLASS(GetHashesFast);
105  RPC_MESSAGE_MEMBER(std::list<crypto::hash>, known_hashes);
106  RPC_MESSAGE_MEMBER(uint64_t, start_height);
109  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, hashes);
110  RPC_MESSAGE_MEMBER(uint64_t, start_height);
111  RPC_MESSAGE_MEMBER(uint64_t, current_height);
114 
115 
116 BEGIN_RPC_MESSAGE_CLASS(GetTransactions);
118  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, tx_hashes);
122  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, missed_hashes);
125 
126 
127 BEGIN_RPC_MESSAGE_CLASS(KeyImagesSpent);
128  enum STATUS {
129  UNSPENT = 0,
132  };
134  RPC_MESSAGE_MEMBER(std::vector<crypto::key_image>, key_images);
137  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, spent_status);
140 
141 
142 BEGIN_RPC_MESSAGE_CLASS(GetTxGlobalOutputIndices);
147  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, output_indices);
150 
151 
152 BEGIN_RPC_MESSAGE_CLASS(GetRandomOutputsForAmounts);
154  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
155  RPC_MESSAGE_MEMBER(uint64_t, count);
158  RPC_MESSAGE_MEMBER(std::vector<amount_with_random_outputs>, amounts_with_outputs);
161 
162 BEGIN_RPC_MESSAGE_CLASS(SendRawTx);
165  RPC_MESSAGE_MEMBER(bool, relay);
168  RPC_MESSAGE_MEMBER(bool, relayed);
171 
172 BEGIN_RPC_MESSAGE_CLASS(StartMining);
174  RPC_MESSAGE_MEMBER(std::string, miner_address);
175  RPC_MESSAGE_MEMBER(uint64_t, threads_count);
176  RPC_MESSAGE_MEMBER(bool, do_background_mining);
177  RPC_MESSAGE_MEMBER(bool, ignore_battery);
182 
183 BEGIN_RPC_MESSAGE_CLASS(GetInfo);
187  RPC_MESSAGE_MEMBER(DaemonInfo, info);
190 
191 BEGIN_RPC_MESSAGE_CLASS(StopMining);
197 
198 BEGIN_RPC_MESSAGE_CLASS(MiningStatus);
202  RPC_MESSAGE_MEMBER(bool, active);
203  RPC_MESSAGE_MEMBER(uint64_t, speed);
204  RPC_MESSAGE_MEMBER(uint64_t, threads_count);
205  RPC_MESSAGE_MEMBER(std::string, address);
206  RPC_MESSAGE_MEMBER(bool, is_background_mining_enabled);
209 
216 
217 BEGIN_RPC_MESSAGE_CLASS(GetBlockHash);
219  RPC_MESSAGE_MEMBER(uint64_t, height);
225 
226 BEGIN_RPC_MESSAGE_CLASS(GetBlockTemplate);
232 
233 BEGIN_RPC_MESSAGE_CLASS(SubmitBlock);
239 
240 BEGIN_RPC_MESSAGE_CLASS(GetLastBlockHeader);
247 
248 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeaderByHash);
256 
257 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeaderByHeight);
259  RPC_MESSAGE_MEMBER(uint64_t, height);
265 
266 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeadersByHeight);
268  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, heights);
271  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::BlockHeaderResponse>, headers);
274 
275 BEGIN_RPC_MESSAGE_CLASS(GetBlock);
281 
282 BEGIN_RPC_MESSAGE_CLASS(GetPeerList);
286  RPC_MESSAGE_MEMBER(std::vector<peer>, white_list);
287  RPC_MESSAGE_MEMBER(std::vector<peer>, gray_list);
290 
291 BEGIN_RPC_MESSAGE_CLASS(SetLogHashRate);
297 
298 BEGIN_RPC_MESSAGE_CLASS(SetLogLevel);
300  RPC_MESSAGE_MEMBER(int8_t, level);
305 
306 BEGIN_RPC_MESSAGE_CLASS(GetTransactionPool);
310  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::tx_in_pool>, transactions);
314 
315 BEGIN_RPC_MESSAGE_CLASS(GetConnections);
321 
322 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeadersRange);
328 
329 BEGIN_RPC_MESSAGE_CLASS(StopDaemon);
335 
336 BEGIN_RPC_MESSAGE_CLASS(StartSaveGraph);
342 
343 BEGIN_RPC_MESSAGE_CLASS(StopSaveGraph);
349 
350 BEGIN_RPC_MESSAGE_CLASS(HardForkInfo);
352  RPC_MESSAGE_MEMBER(uint8_t, version);
355  RPC_MESSAGE_MEMBER(hard_fork_info, info);
358 
359 BEGIN_RPC_MESSAGE_CLASS(GetBans);
365 
366 BEGIN_RPC_MESSAGE_CLASS(SetBans);
372 
373 BEGIN_RPC_MESSAGE_CLASS(FlushTransactionPool);
379 
380 BEGIN_RPC_MESSAGE_CLASS(GetOutputHistogram);
382  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
383  RPC_MESSAGE_MEMBER(uint64_t, min_count);
384  RPC_MESSAGE_MEMBER(uint64_t, max_count);
385  RPC_MESSAGE_MEMBER(bool, unlocked);
386  RPC_MESSAGE_MEMBER(uint64_t, recent_cutoff);
389  RPC_MESSAGE_MEMBER(std::vector<output_amount_count>, histogram);
392 
393 BEGIN_RPC_MESSAGE_CLASS(GetOutputKeys);
395  RPC_MESSAGE_MEMBER(std::vector<output_amount_and_index>, outputs);
398  RPC_MESSAGE_MEMBER(std::vector<output_key_mask_unlocked>, keys);
401 
402 BEGIN_RPC_MESSAGE_CLASS(GetRPCVersion);
406  RPC_MESSAGE_MEMBER(uint32_t, version);
409 
410 BEGIN_RPC_MESSAGE_CLASS(GetPerKBFeeEstimate);
412  RPC_MESSAGE_MEMBER(uint64_t, num_grace_blocks);
415  RPC_MESSAGE_MEMBER(uint64_t, estimated_fee_per_kb);
418 
419 } // namespace rpc
420 
421 } // namespace cryptonote
END_RPC_MESSAGE_REQUEST
Definition: daemon_messages.h:81
uint64_t height
Definition: blockchain.cpp:88
Definition: daemon_messages.h:129
Definition: daemon_messages.h:131
std::unordered_map< crypto::key_image, std::vector< crypto::hash > > key_images_with_tx_hashes
Definition: message_data_structs.h:102
Definition: daemon_messages.h:130
Definition: message_data_structs.h:155
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:224
BEGIN_RPC_MESSAGE_RESPONSE
Definition: daemon_messages.h:82
END_RPC_MESSAGE_RESPONSE
Definition: daemon_messages.h:84
END_RPC_MESSAGE_CLASS
Definition: daemon_messages.h:85
BEGIN_RPC_MESSAGE_CLASS(GetHeight)
RPC_MESSAGE_MEMBER(uint64_t, height)
Definition: message_data_structs.h:54
uint8_t version
Definition: blockchain.cpp:87
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:90
#define blocks
Definition: sha512-hash.c:11
STATUS
Definition: daemon_messages.h:128
BEGIN_RPC_MESSAGE_REQUEST
Definition: daemon_messages.h:80
#define COMMA()
Definition: daemon_messages.h:65
POD_CLASS hash
Definition: hash.h:49
Definition: cryptonote_basic.h:182