diff --git a/rpc/types/src/defaults.rs b/rpc/types/src/defaults.rs index 27aac90a..8fe7b41e 100644 --- a/rpc/types/src/defaults.rs +++ b/rpc/types/src/defaults.rs @@ -11,7 +11,7 @@ use std::borrow::Cow; //---------------------------------------------------------------------------------------------------- TODO -/// Default [`bool`] type used in request/response types. +/// Default [`bool`] type used in request/response types, `false`. #[inline] pub(crate) const fn default_bool() -> bool { false diff --git a/rpc/types/src/misc.rs b/rpc/types/src/misc.rs index a9cdfd58..e938163f 100644 --- a/rpc/types/src/misc.rs +++ b/rpc/types/src/misc.rs @@ -416,7 +416,7 @@ define_struct_and_impl_epee! { #[doc = monero_definition_link!( cc73fe71162d564ffda8e549b79a350bca53c454, "rpc/core_rpc_server_commands_defs.h", - 512..=521 + 538..=553 )] /// Used in [`crate::bin::GetOutsRequest`]. #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -491,6 +491,52 @@ impl EpeeValue for PoolInfoExtent { } } +#[doc = monero_definition_link!( + cc73fe71162d564ffda8e549b79a350bca53c454, + "rpc/core_rpc_server_commands_defs.h", + 389..=428 +)] +/// Used in [`crate::other::GetTransactionsResponse`]. +#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct TxEntry { + pub as_hex: String, + pub as_json: String, + pub block_height: u64, + pub block_timestamp: u64, + pub confirmations: u64, + pub double_spend_seen: bool, + pub in_pool: bool, + pub output_indices: Vec<u64>, + pub prunable_as_hex: String, + pub prunable_hash: String, + pub pruned_as_hex: String, + pub received_timestamp: u64, + pub relayed: bool, + pub tx_hash: String, +} + +// TODO: custom epee +// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/cryptonote_protocol/cryptonote_protocol_defs.h#L406-427> +#[cfg(feature = "epee")] +epee_object! { + TxEntry, + as_hex: String, + as_json: String, // TODO: should be its own struct + block_height: u64, + block_timestamp: u64, + confirmations: u64, + double_spend_seen: bool, + in_pool: bool, + output_indices: Vec<u64>, + prunable_as_hex: String, + prunable_hash: String, + pruned_as_hex: String, + received_timestamp: u64, + relayed: bool, + tx_hash: String, +} + //---------------------------------------------------------------------------------------------------- Status /// RPC response status. /// diff --git a/rpc/types/src/other.rs b/rpc/types/src/other.rs index c8bc6208..da4dd723 100644 --- a/rpc/types/src/other.rs +++ b/rpc/types/src/other.rs @@ -4,7 +4,9 @@ //! - <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server_commands_defs.h> //---------------------------------------------------------------------------------------------------- Import -use crate::{base::ResponseBase, macros::define_request_and_response}; +use crate::{ + base::ResponseBase, defaults::default_bool, macros::define_request_and_response, misc::TxEntry, +}; //---------------------------------------------------------------------------------------------------- TODO define_request_and_response! { @@ -19,6 +21,31 @@ define_request_and_response! { } } +define_request_and_response! { + get_transactions, + cc73fe71162d564ffda8e549b79a350bca53c454 => + core_rpc_server_commands_defs.h => 370..=451, + GetTransactions, + Request { + txs_hashes: Vec<String>, + // FIXME: this is documented as optional but it isn't serialized as an optional + // but it is set _somewhere_ to false in `monerod` + // <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server_commands_defs.h#L382> + #[cfg_attr(feature = "serde", serde(default = "default_bool"))] + decode_as_json: bool = default_bool(), + #[cfg_attr(feature = "serde", serde(default = "default_bool"))] + prune: bool = default_bool(), + #[cfg_attr(feature = "serde", serde(default = "default_bool"))] + split: bool = default_bool(), + }, + ResponseBase { + txs_as_hex: Vec<String>, + txs_as_json: Vec<String>, + missed_tx: Vec<String>, + txs: Vec<TxEntry>, + } +} + define_request_and_response! { save_bc, cc73fe71162d564ffda8e549b79a350bca53c454 =>