Monero
message_data_structs.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 "crypto/hash.h"
34 #include "ringct/rctSigs.h"
35 #include "rpc/rpc_handler.h"
36 
37 #include <unordered_map>
38 #include <vector>
39 
40 namespace cryptonote
41 {
42 
43 namespace rpc
44 {
45 
47  {
49  std::vector<cryptonote::transaction> transactions;
50  };
51 
52  typedef std::vector<uint64_t> tx_output_indices;
53 
54  typedef std::vector<tx_output_indices> block_output_indices;
55 
57  {
59  bool in_pool;
60  uint64_t height;
61  };
62 
64  {
65  uint64_t amount_index;
67  };
68 
69  typedef std::vector<output_key_and_amount_index> outputs_for_amount;
70 
72  {
73  uint64_t amount;
75  };
76 
77  struct peer
78  {
79  uint64_t id;
80  uint32_t ip;
81  uint16_t port;
82  uint16_t rpc_port;
84  uint64_t last_seen;
85  uint32_t pruning_seed;
86  };
87 
88  struct tx_in_pool
89  {
92  uint64_t blob_size;
93  uint64_t weight;
94  uint64_t fee;
100  uint64_t receive_time;
102  bool relayed;
105  };
106 
107  typedef std::unordered_map<crypto::key_image, std::vector<crypto::hash> > key_images_with_tx_hashes;
108 
110  {
111  uint64_t amount;
112  uint64_t total_count;
113  uint64_t unlocked_count;
114  uint64_t recent_count;
115  };
116 
118  {
119  uint64_t amount;
120  uint64_t index;
121  };
122 
124  {
127  bool unlocked;
128  };
129 
131  {
132  uint8_t version;
133  bool enabled;
134  uint32_t window;
135  uint32_t votes;
136  uint32_t threshold;
137  uint8_t voting;
138  uint32_t state;
139  uint64_t earliest_height;
140  };
141 
142  //required by JSON-RPC 2.0 spec
143  struct error
144  {
145  // not really using code, maybe later.
146  error() : use(false), code(1) { }
147 
148  bool use; // do not serialize
149 
150  int32_t code;
151 
152  // not required by spec, but int error codes aren't perfect
153  std::string error_str;
154 
155  std::string message;
156 
157  //TODO: data member? not required, may want later.
158  };
159 
161  {
162  uint64_t major_version;
163  uint64_t minor_version;
164  uint64_t timestamp;
166  uint32_t nonce;
167  uint64_t height;
168  uint64_t depth;
171  uint64_t difficulty;
172  uint64_t reward;
173  };
174 
175  struct DaemonInfo
176  {
177  uint64_t height;
178  uint64_t target_height;
180  uint64_t difficulty;
181  uint64_t target;
182  uint64_t tx_count;
183  uint64_t tx_pool_size;
189  bool mainnet;
190  bool testnet;
191  bool stagenet;
192  std::string nettype;
199  uint64_t adjusted_time;
201  uint64_t start_time;
202  std::string version;
203  };
204 
206  {
208  uint64_t amount;
210  };
211 } // namespace rpc
212 
213 } // namespace cryptonote
cryptonote::rpc::DaemonInfo
Definition: message_data_structs.h:176
cryptonote::rpc::output_distribution::amount
uint64_t amount
Definition: message_data_structs.h:208
cryptonote::rpc::BlockHeaderResponse::depth
uint64_t depth
Definition: message_data_structs.h:168
cryptonote::rpc::tx_in_pool::relayed
bool relayed
Definition: message_data_structs.h:102
cryptonote::rpc::BlockHeaderResponse::minor_version
uint64_t minor_version
Definition: message_data_structs.h:163
cryptonote::rpc::amount_with_random_outputs
Definition: message_data_structs.h:72
cryptonote::rpc::output_key_mask_unlocked::unlocked
bool unlocked
Definition: message_data_structs.h:127
cryptonote::rpc::DaemonInfo::wide_cumulative_difficulty
cryptonote::difficulty_type wide_cumulative_difficulty
Definition: message_data_structs.h:194
cryptonote_basic.h
cryptonote::rpc::tx_in_pool::last_failed_block_height
uint64_t last_failed_block_height
Definition: message_data_structs.h:99
cryptonote::rpc::hard_fork_info
Definition: message_data_structs.h:131
cryptonote::rpc::DaemonInfo::block_size_median
uint64_t block_size_median
Definition: message_data_structs.h:198
cryptonote::rpc::tx_in_pool::blob_size
uint64_t blob_size
Definition: message_data_structs.h:92
cryptonote::rpc::output_key_and_amount_index::key
crypto::public_key key
Definition: message_data_structs.h:66
cryptonote::rpc::DaemonInfo::white_peerlist_size
uint64_t white_peerlist_size
Definition: message_data_structs.h:187
cryptonote::rpc::output_key_mask_unlocked::mask
rct::key mask
Definition: message_data_structs.h:126
cryptonote::rpc::output_key_mask_unlocked::key
crypto::public_key key
Definition: message_data_structs.h:125
cryptonote::rpc::peer::pruning_seed
uint32_t pruning_seed
Definition: message_data_structs.h:85
cryptonote::rpc::output_amount_count
Definition: message_data_structs.h:110
cryptonote::rpc::hard_fork_info::version
uint8_t version
Definition: message_data_structs.h:132
cryptonote::rpc::BlockHeaderResponse::reward
uint64_t reward
Definition: message_data_structs.h:172
rct::key
Definition: rctTypes.h:79
cryptonote::rpc::output_distribution_data
Definition: rpc_handler.h:46
cryptonote::rpc::DaemonInfo::nettype
std::string nettype
Definition: message_data_structs.h:192
cryptonote::rpc::output_distribution
Definition: message_data_structs.h:206
cryptonote::rpc::output_key_mask_unlocked
Definition: message_data_structs.h:124
cryptonote::rpc::hard_fork_info::window
uint32_t window
Definition: message_data_structs.h:134
cryptonote::rpc::tx_in_pool::last_failed_block_hash
crypto::hash last_failed_block_hash
Definition: message_data_structs.h:98
cryptonote::rpc::peer::rpc_port
uint16_t rpc_port
Definition: message_data_structs.h:82
cryptonote::rpc::BlockHeaderResponse::timestamp
uint64_t timestamp
Definition: message_data_structs.h:164
cryptonote::rpc::tx_in_pool::last_relayed_time
uint64_t last_relayed_time
Definition: message_data_structs.h:101
cryptonote::rpc::DaemonInfo::mainnet
bool mainnet
Definition: message_data_structs.h:189
cryptonote::rpc::output_amount_count::recent_count
uint64_t recent_count
Definition: message_data_structs.h:114
cryptonote::rpc::transaction_info::in_pool
bool in_pool
Definition: message_data_structs.h:59
cryptonote::rpc::BlockHeaderResponse::wide_difficulty
cryptonote::difficulty_type wide_difficulty
Definition: message_data_structs.h:170
cryptonote::difficulty_type
boost::multiprecision::uint128_t difficulty_type
Definition: difficulty.h:41
cryptonote::rpc::tx_in_pool::double_spend_seen
bool double_spend_seen
Definition: message_data_structs.h:104
cryptonote::rpc::tx_output_indices
std::vector< uint64_t > tx_output_indices
Definition: message_data_structs.h:52
cryptonote::rpc::DaemonInfo::incoming_connections_count
uint64_t incoming_connections_count
Definition: message_data_structs.h:186
cryptonote::rpc::block_with_transactions
Definition: message_data_structs.h:47
cryptonote::rpc::BlockHeaderResponse::major_version
uint64_t major_version
Definition: message_data_structs.h:162
cryptonote::rpc::output_amount_count::amount
uint64_t amount
Definition: message_data_structs.h:111
cryptonote::rpc::block_with_transactions::block
cryptonote::block block
Definition: message_data_structs.h:48
cryptonote::rpc::BlockHeaderResponse::hash
crypto::hash hash
Definition: message_data_structs.h:169
rctSigs.h
cryptonote::rpc::output_distribution::data
output_distribution_data data
Definition: message_data_structs.h:207
cryptonote::rpc::BlockHeaderResponse
Definition: message_data_structs.h:161
cryptonote::rpc::tx_in_pool::kept_by_block
bool kept_by_block
Definition: message_data_structs.h:97
cryptonote::rpc::tx_in_pool::receive_time
uint64_t receive_time
Definition: message_data_structs.h:100
cryptonote::rpc::DaemonInfo::tx_count
uint64_t tx_count
Definition: message_data_structs.h:182
cryptonote::rpc::DaemonInfo::testnet
bool testnet
Definition: message_data_structs.h:190
cryptonote::rpc::BlockHeaderResponse::height
uint64_t height
Definition: message_data_structs.h:167
cryptonote::rpc::peer::ip
uint32_t ip
Definition: message_data_structs.h:80
cryptonote::rpc::error::use
bool use
Definition: message_data_structs.h:148
cryptonote::rpc::peer
Definition: message_data_structs.h:78
cryptonote::rpc::output_key_and_amount_index
Definition: message_data_structs.h:64
cryptonote::rpc::output_amount_and_index::index
uint64_t index
Definition: message_data_structs.h:120
cryptonote::rpc::DaemonInfo::tx_pool_size
uint64_t tx_pool_size
Definition: message_data_structs.h:183
cryptonote::rpc::DaemonInfo::outgoing_connections_count
uint64_t outgoing_connections_count
Definition: message_data_structs.h:185
cryptonote::rpc::tx_in_pool::max_used_block_hash
crypto::hash max_used_block_hash
Definition: message_data_structs.h:95
cryptonote::rpc::DaemonInfo::block_weight_median
uint64_t block_weight_median
Definition: message_data_structs.h:200
cryptonote::rpc::peer::port
uint16_t port
Definition: message_data_structs.h:81
cryptonote::rpc::BlockHeaderResponse::nonce
uint32_t nonce
Definition: message_data_structs.h:166
cryptonote::rpc::tx_in_pool::weight
uint64_t weight
Definition: message_data_structs.h:93
cryptonote::rpc::error::error
error()
Definition: message_data_structs.h:146
cryptonote::rpc::tx_in_pool::tx_hash
crypto::hash tx_hash
Definition: message_data_structs.h:91
cryptonote::block
Definition: cryptonote_basic.h:464
cryptonote::rpc::transaction_info::height
uint64_t height
Definition: message_data_structs.h:60
cryptonote::rpc::peer::rpc_credits_per_hash
uint32_t rpc_credits_per_hash
Definition: message_data_structs.h:83
cryptonote
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
cryptonote::rpc::output_distribution::cumulative
bool cumulative
Definition: message_data_structs.h:209
cryptonote::rpc::DaemonInfo::difficulty
uint64_t difficulty
Definition: message_data_structs.h:180
cryptonote::rpc::DaemonInfo::cumulative_difficulty
uint64_t cumulative_difficulty
Definition: message_data_structs.h:195
cryptonote::rpc::key_images_with_tx_hashes
std::unordered_map< crypto::key_image, std::vector< crypto::hash > > key_images_with_tx_hashes
Definition: message_data_structs.h:107
false
#define false
Definition: stdbool.h:37
cryptonote::rpc::peer::id
uint64_t id
Definition: message_data_structs.h:79
cryptonote::rpc::DaemonInfo::grey_peerlist_size
uint64_t grey_peerlist_size
Definition: message_data_structs.h:188
cryptonote::rpc::block_output_indices
std::vector< tx_output_indices > block_output_indices
Definition: message_data_structs.h:54
cryptonote::rpc::error::message
std::string message
Definition: message_data_structs.h:155
cryptonote::rpc::block_with_transactions::transactions
std::vector< cryptonote::transaction > transactions
Definition: message_data_structs.h:49
cryptonote::rpc::amount_with_random_outputs::amount
uint64_t amount
Definition: message_data_structs.h:73
cryptonote::rpc::DaemonInfo::height
uint64_t height
Definition: message_data_structs.h:177
cryptonote::rpc::transaction_info
Definition: message_data_structs.h:57
difficulty.h
cryptonote::rpc::outputs_for_amount
std::vector< output_key_and_amount_index > outputs_for_amount
Definition: message_data_structs.h:69
crypto::public_key
POD_CLASS public_key
Definition: crypto.h:61
cryptonote::rpc::DaemonInfo::wide_difficulty
cryptonote::difficulty_type wide_difficulty
Definition: message_data_structs.h:179
cryptonote::rpc::DaemonInfo::top_block_hash
crypto::hash top_block_hash
Definition: message_data_structs.h:193
cryptonote::rpc::tx_in_pool::tx
cryptonote::transaction tx
Definition: message_data_structs.h:90
cryptonote::rpc::DaemonInfo::adjusted_time
uint64_t adjusted_time
Definition: message_data_structs.h:199
cryptonote::rpc::DaemonInfo::stagenet
bool stagenet
Definition: message_data_structs.h:191
rpc_handler.h
cryptonote::rpc::DaemonInfo::start_time
uint64_t start_time
Definition: message_data_structs.h:201
cryptonote::rpc::hard_fork_info::votes
uint32_t votes
Definition: message_data_structs.h:135
cryptonote::rpc::output_key_and_amount_index::amount_index
uint64_t amount_index
Definition: message_data_structs.h:65
cryptonote::rpc::DaemonInfo::version
std::string version
Definition: message_data_structs.h:202
hash.h
cryptonote::rpc::output_amount_and_index::amount
uint64_t amount
Definition: message_data_structs.h:119
cryptonote::rpc::error::code
int32_t code
Definition: message_data_structs.h:150
cryptonote::transaction
Definition: cryptonote_basic.h:194
cryptonote::rpc::peer::last_seen
uint64_t last_seen
Definition: message_data_structs.h:84
cryptonote::rpc::error
Definition: message_data_structs.h:144
cryptonote::rpc::output_amount_count::total_count
uint64_t total_count
Definition: message_data_structs.h:112
cryptonote::rpc::tx_in_pool::do_not_relay
bool do_not_relay
Definition: message_data_structs.h:103
cryptonote::rpc::DaemonInfo::target_height
uint64_t target_height
Definition: message_data_structs.h:178
cryptonote::rpc::DaemonInfo::block_weight_limit
uint64_t block_weight_limit
Definition: message_data_structs.h:197
cryptonote::rpc::DaemonInfo::alt_blocks_count
uint64_t alt_blocks_count
Definition: message_data_structs.h:184
cryptonote::rpc::amount_with_random_outputs::outputs
outputs_for_amount outputs
Definition: message_data_structs.h:74
cryptonote::rpc::hard_fork_info::earliest_height
uint64_t earliest_height
Definition: message_data_structs.h:139
cryptonote::rpc::hard_fork_info::state
uint32_t state
Definition: message_data_structs.h:138
cryptonote::rpc::hard_fork_info::enabled
bool enabled
Definition: message_data_structs.h:133
cryptonote::rpc::BlockHeaderResponse::prev_id
crypto::hash prev_id
Definition: message_data_structs.h:165
cryptonote::rpc::DaemonInfo::block_size_limit
uint64_t block_size_limit
Definition: message_data_structs.h:196
cryptonote::rpc::tx_in_pool
Definition: message_data_structs.h:89
cryptonote::rpc::DaemonInfo::target
uint64_t target
Definition: message_data_structs.h:181
cryptonote::rpc::error::error_str
std::string error_str
Definition: message_data_structs.h:153
cryptonote::rpc::output_amount_and_index
Definition: message_data_structs.h:118
cryptonote::rpc::tx_in_pool::max_used_block_height
uint64_t max_used_block_height
Definition: message_data_structs.h:96
cryptonote::rpc::output_amount_count::unlocked_count
uint64_t unlocked_count
Definition: message_data_structs.h:113
cryptonote::rpc::tx_in_pool::fee
uint64_t fee
Definition: message_data_structs.h:94
cryptonote::rpc::hard_fork_info::voting
uint8_t voting
Definition: message_data_structs.h:137
cryptonote::rpc::transaction_info::transaction
cryptonote::transaction transaction
Definition: message_data_structs.h:58
cryptonote::rpc::hard_fork_info::threshold
uint32_t threshold
Definition: message_data_structs.h:136
cryptonote::rpc::BlockHeaderResponse::difficulty
uint64_t difficulty
Definition: message_data_structs.h:171
crypto::hash
POD_CLASS hash
Definition: hash.h:48