other: IsKeyImageSpent, SendRawTransaction

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

View file

@ -17,6 +17,12 @@ pub(crate) const fn default_bool() -> bool {
false
}
/// Default [`bool`] type used in _some_ request/response types, `true`.
#[inline]
pub(crate) const fn default_bool_true() -> bool {
true
}
/// Default `Cow<'static, str` type used in request/response types.
#[inline]
pub(crate) const fn default_cow_str() -> Cow<'static, str> {

View file

@ -537,6 +537,38 @@ epee_object! {
tx_hash: String,
}
//---------------------------------------------------------------------------------------------------- TODO
/// Used in [`crate::other::IsKeyImageSpentResponse`].
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[repr(u8)]
pub enum KeyImageSpentStatus {
Unspent = 0,
SpentInBlockchain = 1,
SpentInPool = 2,
}
#[cfg(feature = "epee")]
impl EpeeValue for KeyImageSpentStatus {
const MARKER: Marker = <String as EpeeValue>::MARKER;
fn read<B: Buf>(r: &mut B, marker: &Marker) -> cuprate_epee_encoding::Result<Self> {
todo!()
}
fn should_write(&self) -> bool {
todo!()
}
fn epee_default_value() -> Option<Self> {
todo!()
}
fn write<B: BufMut>(self, w: &mut B) -> cuprate_epee_encoding::Result<()> {
todo!()
}
}
//---------------------------------------------------------------------------------------------------- Status
/// RPC response status.
///

View file

@ -5,7 +5,10 @@
//---------------------------------------------------------------------------------------------------- Import
use crate::{
base::ResponseBase, defaults::default_bool, macros::define_request_and_response, misc::TxEntry,
base::{AccessResponseBase, ResponseBase},
defaults::{default_bool, default_bool_true},
macros::define_request_and_response,
misc::TxEntry,
};
//---------------------------------------------------------------------------------------------------- TODO
@ -38,7 +41,7 @@ define_request_and_response! {
#[cfg_attr(feature = "serde", serde(default = "default_bool"))]
split: bool = default_bool(),
},
ResponseBase {
AccessResponseBase {
txs_as_hex: Vec<String>,
txs_as_json: Vec<String>,
missed_tx: Vec<String>,
@ -46,6 +49,59 @@ define_request_and_response! {
}
}
define_request_and_response! {
get_alt_blocks_hashes,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 370..=451,
GetAltBlocksHashes,
Request {},
AccessResponseBase {
blks_hashes: Vec<String>,
}
}
define_request_and_response! {
is_key_image_spent,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 370..=451,
IsKeyImageSpent,
Request {
key_images: Vec<String>,
},
AccessResponseBase {
spent_status: Vec<u8>, // TODO: should be `KeyImageSpentStatus`.
}
}
define_request_and_response! {
send_raw_transaction,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 370..=451,
SendRawTransaction,
Request {
tx_as_hex: String,
#[cfg_attr(feature = "serde", serde(default = "default_bool"))]
do_not_relay: bool = default_bool(),
#[cfg_attr(feature = "serde", serde(default = "default_bool_true"))]
do_sanity_checks: bool = default_bool_true(),
},
AccessResponseBase {
double_spend: bool,
fee_too_low: bool,
invalid_input: bool,
invalid_output: bool,
low_mixin: bool,
nonzero_unlock_time: bool,
not_relayed: bool,
overspend: bool,
reason: String,
sanity_check_failed: bool,
too_big: bool,
too_few_outputs: bool,
tx_extra_too_big: bool,
}
}
define_request_and_response! {
save_bc,
cc73fe71162d564ffda8e549b79a350bca53c454 =>