1use cuprate_hex::{Hex, HexVec};
9use cuprate_types::HardFork;
10
11#[cfg(any(feature = "epee", feature = "serde"))]
12use crate::defaults::default;
13
14use crate::macros::monero_definition_link;
15
16macro_rules! define_struct_and_impl_epee {
28 ($(
29 $( #[$struct_attr:meta] )*
31 $struct_name:ident {
33 $(
35 $( #[$field_attr:meta] )* $field_name:ident: $field_type:ty $(= $field_default:expr_2021)?,
38 )*
39 }
40 )*) => {
41 $(
42 #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
43 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
44 #[cfg_attr(feature = "serde", serde(default))]
45 $( #[$struct_attr] )*
46 pub struct $struct_name {
47 $(
48 $( #[$field_attr] )*
49 pub $field_name: $field_type,
50 )*
51 }
52
53 #[cfg(feature = "epee")]
54 cuprate_epee_encoding::epee_object! {
55 $struct_name,
56 $(
57 $field_name: $field_type $(= $field_default)?,
58 )*
59 }
60 )*
61 };
62}
63
64define_struct_and_impl_epee! {
66 #[doc = monero_definition_link!(
67 "cc73fe71162d564ffda8e549b79a350bca53c454",
68 "rpc/core_rpc_server_commands_defs.h",
69 1163..=1212
70 )]
71 BlockHeader {
79 block_size: u64,
80 block_weight: u64,
81 cumulative_difficulty_top64: u64,
82 cumulative_difficulty: u64,
83 depth: u64,
84 difficulty_top64: u64,
85 difficulty: u64,
86 hash: Hex<32>,
87 height: u64,
88 long_term_weight: u64,
89 major_version: HardFork,
90 miner_tx_hash: Hex<32>,
91 minor_version: u8,
92 nonce: u32,
93 num_txes: u64,
94 orphan_status: bool,
95 pow_hash: HexVec,
97 prev_hash: Hex<32>,
98 reward: u64,
99 timestamp: u64,
100 wide_cumulative_difficulty: String,
101 wide_difficulty: String,
102 }
103}
104
105define_struct_and_impl_epee! {
106 #[doc = monero_definition_link!(
107 "cc73fe71162d564ffda8e549b79a350bca53c454",
108 "cryptonote_protocol/cryptonote_protocol_defs.h",
109 47..=116
110 )]
111 ConnectionInfo {
113 address: String,
114 address_type: cuprate_types::AddressType,
115 avg_download: u64,
116 avg_upload: u64,
117 connection_id: String,
118 current_download: u64,
119 current_upload: u64,
120 height: u64,
121 host: String,
122 incoming: bool,
123 ip: String,
124 live_time: u64,
125 localhost: bool,
126 local_ip: bool,
127 peer_id: String,
128 port: String,
129 pruning_seed: u32,
130 recv_count: u64,
131 recv_idle_time: u64,
132 rpc_credits_per_hash: u32,
133 rpc_port: u16,
134 send_count: u64,
135 send_idle_time: u64,
136 state: cuprate_types::ConnectionState,
140 support_flags: u32,
141 }
142}
143
144define_struct_and_impl_epee! {
145 #[doc = monero_definition_link!(
146 "cc73fe71162d564ffda8e549b79a350bca53c454",
147 "rpc/core_rpc_server_commands_defs.h",
148 2034..=2047
149 )]
150 SetBan {
152 host: String,
153 ip: u32,
154 ban: bool,
155 seconds: u32,
156 }
157}
158
159define_struct_and_impl_epee! {
160 #[doc = monero_definition_link!(
161 "cc73fe71162d564ffda8e549b79a350bca53c454",
162 "rpc/core_rpc_server_commands_defs.h",
163 1999..=2010
164 )]
165 GetBan {
167 host: String,
168 ip: u32,
169 seconds: u32,
170 }
171}
172
173define_struct_and_impl_epee! {
174 #[doc = monero_definition_link!(
175 "cc73fe71162d564ffda8e549b79a350bca53c454",
176 "rpc/core_rpc_server_commands_defs.h",
177 2139..=2156
178 )]
179 #[derive(Copy)]
180 HistogramEntry {
182 amount: u64,
183 total_instances: u64,
184 unlocked_instances: u64,
185 recent_instances: u64,
186 }
187}
188
189define_struct_and_impl_epee! {
190 #[doc = monero_definition_link!(
191 "cc73fe71162d564ffda8e549b79a350bca53c454",
192 "rpc/core_rpc_server_commands_defs.h",
193 2289..=2310
194 )]
195 ChainInfo {
197 block_hash: Hex<32>,
198 block_hashes: Vec<Hex<32>>,
199 difficulty: u64,
200 difficulty_top64: u64,
201 height: u64,
202 length: u64,
203 main_chain_parent_block: Hex<32>,
204 wide_difficulty: String,
205 }
206}
207
208define_struct_and_impl_epee! {
209 #[doc = monero_definition_link!(
210 "cc73fe71162d564ffda8e549b79a350bca53c454",
211 "rpc/core_rpc_server_commands_defs.h",
212 2393..=2400
213 )]
214 SyncInfoPeer {
216 info: ConnectionInfo,
217 }
218}
219
220define_struct_and_impl_epee! {
221 #[doc = monero_definition_link!(
222 "cc73fe71162d564ffda8e549b79a350bca53c454",
223 "rpc/core_rpc_server_commands_defs.h",
224 2402..=2421
225 )]
226 Span {
228 connection_id: String,
229 nblocks: u64,
230 rate: u32,
231 remote_address: String,
232 size: u64,
233 speed: u32,
234 start_block_height: u64,
235 }
236}
237
238define_struct_and_impl_epee! {
239 #[doc = monero_definition_link!(
240 "cc73fe71162d564ffda8e549b79a350bca53c454",
241 "rpc/core_rpc_server_commands_defs.h",
242 512..=521
243 )]
244 #[derive(Copy)]
245 GetOutputsOut {
250 amount: u64,
251 index: u64,
252 }
253}
254
255define_struct_and_impl_epee! {
256 #[doc = monero_definition_link!(
257 "cc73fe71162d564ffda8e549b79a350bca53c454",
258 "rpc/core_rpc_server_commands_defs.h",
259 582..=597
260 )]
261 OutKey {
263 key: Hex<32>,
264 mask: Hex<32>,
265 unlocked: bool,
266 height: u64,
267 txid: HexVec,
269 }
270}
271
272define_struct_and_impl_epee! {
273 #[doc = monero_definition_link!(
274 "cc73fe71162d564ffda8e549b79a350bca53c454",
275 "rpc/core_rpc_server_commands_defs.h",
276 538..=553
277 )]
278 #[derive(Copy)]
279 OutKeyBin {
281 key: [u8; 32],
282 mask: [u8; 32],
283 unlocked: bool,
284 height: u64,
285 txid: [u8; 32],
286 }
287}
288
289define_struct_and_impl_epee! {
290 #[doc = monero_definition_link!(
291 "cc73fe71162d564ffda8e549b79a350bca53c454",
292 "rpc/core_rpc_server_commands_defs.h",
293 1519..=1556
294 )]
295 TxInfo {
297 blob_size: u64,
298 do_not_relay: bool,
299 double_spend_seen: bool,
300 fee: u64,
301 id_hash: Hex<32>,
302 kept_by_block: bool,
303 last_failed_height: u64,
304 last_failed_id_hash: Hex<32>,
305 last_relayed_time: u64,
306 max_used_block_height: u64,
307 max_used_block_id_hash: Hex<32>,
308 receive_time: u64,
309 relayed: bool,
310 tx_blob: HexVec,
311 tx_json: cuprate_types::json::tx::Transaction,
312 weight: u64 = default::<u64>(),
313 }
314}
315
316define_struct_and_impl_epee! {
317 #[doc = monero_definition_link!(
318 "cc73fe71162d564ffda8e549b79a350bca53c454",
319 "rpc/core_rpc_server_commands_defs.h",
320 1558..=1567
321 )]
322 SpentKeyImageInfo {
324 id_hash: Hex<32>,
325 txs_hashes: Vec<Hex<32>>,
326 }
327}
328
329#[cfg(test)]
331mod test {}