other: GetTransactions

This commit is contained in:
hinto.janai 2024-07-07 18:06:56 -04:00
parent a694ac5667
commit 113c27b8d3
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
3 changed files with 76 additions and 3 deletions

View file

@ -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

View file

@ -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.
///

View file

@ -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 =>