mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-09 12:29:41 +00:00
Compare commits
6 commits
ea80e666b2
...
d86156f429
Author | SHA1 | Date | |
---|---|---|---|
|
d86156f429 | ||
|
45b5a241ab | ||
|
c06d0a47a2 | ||
|
7dbd514a2d | ||
|
33c31871e1 | ||
|
aa94d93f4d |
7 changed files with 59 additions and 38 deletions
|
@ -16,7 +16,7 @@ epee = ["dep:cuprate-epee-encoding"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cuprate-epee-encoding = { path = "../../net/epee-encoding", optional = true }
|
cuprate-epee-encoding = { path = "../../net/epee-encoding", optional = true }
|
||||||
cuprate-fixed-bytes = { path = "../../net/fixed-bytes" }
|
cuprate-fixed-bytes = { path = "../../net/fixed-bytes" }
|
||||||
cuprate-types = { path = "../../types" }
|
cuprate-types = { path = "../../types", default-features = false, features = ["epee", "serde"] }
|
||||||
|
|
||||||
paste = { workspace = true }
|
paste = { workspace = true }
|
||||||
serde = { workspace = true, optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
|
|
|
@ -635,7 +635,9 @@ define_request_and_response! {
|
||||||
AccessResponseBase {
|
AccessResponseBase {
|
||||||
blob: String,
|
blob: String,
|
||||||
block_header: BlockHeader,
|
block_header: BlockHeader,
|
||||||
json: String, // FIXME: this should be defined in a struct, it has many fields.
|
/// `cuprate_rpc_types::json::block::Block` should be used
|
||||||
|
/// to create this JSON string in a type-safe manner.
|
||||||
|
json: String,
|
||||||
miner_tx_hash: String,
|
miner_tx_hash: String,
|
||||||
tx_hashes: Vec<String> = default_vec::<String>(), "default_vec",
|
tx_hashes: Vec<String> = default_vec::<String>(), "default_vec",
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,32 +71,24 @@ use cuprate_epee_encoding::{
|
||||||
pub enum TxEntry {
|
pub enum TxEntry {
|
||||||
/// This entry exists in the transaction pool.
|
/// This entry exists in the transaction pool.
|
||||||
InPool {
|
InPool {
|
||||||
as_hex: String,
|
/// This field is [flattened](https://serde.rs/field-attrs.html#flatten).
|
||||||
as_json: String,
|
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||||
|
prefix: TxEntryPrefix,
|
||||||
block_height: u64,
|
block_height: u64,
|
||||||
block_timestamp: u64,
|
block_timestamp: u64,
|
||||||
confirmations: u64,
|
confirmations: u64,
|
||||||
double_spend_seen: bool,
|
|
||||||
output_indices: Vec<u64>,
|
output_indices: Vec<u64>,
|
||||||
prunable_as_hex: String,
|
|
||||||
prunable_hash: String,
|
|
||||||
pruned_as_hex: String,
|
|
||||||
tx_hash: String,
|
|
||||||
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_true"))]
|
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_true"))]
|
||||||
/// Will always be serialized as `true`.
|
/// Will always be serialized as `true`.
|
||||||
in_pool: bool,
|
in_pool: bool,
|
||||||
},
|
},
|
||||||
/// This entry _does not_ exist in the transaction pool.
|
/// This entry _does not_ exist in the transaction pool.
|
||||||
NotInPool {
|
NotInPool {
|
||||||
as_hex: String,
|
/// This field is [flattened](https://serde.rs/field-attrs.html#flatten).
|
||||||
as_json: String,
|
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||||
double_spend_seen: bool,
|
prefix: TxEntryPrefix,
|
||||||
prunable_as_hex: String,
|
|
||||||
prunable_hash: String,
|
|
||||||
pruned_as_hex: String,
|
|
||||||
received_timestamp: u64,
|
received_timestamp: u64,
|
||||||
relayed: bool,
|
relayed: bool,
|
||||||
tx_hash: String,
|
|
||||||
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_false"))]
|
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_false"))]
|
||||||
/// Will always be serialized as `false`.
|
/// Will always be serialized as `false`.
|
||||||
in_pool: bool,
|
in_pool: bool,
|
||||||
|
@ -106,20 +98,29 @@ pub enum TxEntry {
|
||||||
impl Default for TxEntry {
|
impl Default for TxEntry {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::NotInPool {
|
Self::NotInPool {
|
||||||
as_hex: String::default(),
|
prefix: Default::default(),
|
||||||
as_json: String::default(),
|
|
||||||
double_spend_seen: bool::default(),
|
|
||||||
prunable_as_hex: String::default(),
|
|
||||||
prunable_hash: String::default(),
|
|
||||||
pruned_as_hex: String::default(),
|
|
||||||
received_timestamp: u64::default(),
|
received_timestamp: u64::default(),
|
||||||
relayed: bool::default(),
|
relayed: bool::default(),
|
||||||
tx_hash: String::default(),
|
|
||||||
in_pool: false,
|
in_pool: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Common fields in all [`TxEntry`] variants.
|
||||||
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
pub struct TxEntryPrefix {
|
||||||
|
as_hex: String,
|
||||||
|
/// `cuprate_rpc_types::json::tx::Transaction` should be used
|
||||||
|
/// to create this JSON string in a type-safe manner.
|
||||||
|
as_json: String,
|
||||||
|
double_spend_seen: bool,
|
||||||
|
tx_hash: String,
|
||||||
|
prunable_as_hex: String,
|
||||||
|
prunable_hash: String,
|
||||||
|
pruned_as_hex: String,
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Epee
|
//---------------------------------------------------------------------------------------------------- Epee
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
impl EpeeObjectBuilder<TxEntry> for () {
|
impl EpeeObjectBuilder<TxEntry> for () {
|
||||||
|
|
|
@ -140,6 +140,8 @@ define_request_and_response! {
|
||||||
#[doc = serde_doc_test!(GET_TRANSACTIONS_RESPONSE)]
|
#[doc = serde_doc_test!(GET_TRANSACTIONS_RESPONSE)]
|
||||||
AccessResponseBase {
|
AccessResponseBase {
|
||||||
txs_as_hex: Vec<String> = default_vec::<String>(), "default_vec",
|
txs_as_hex: Vec<String> = default_vec::<String>(), "default_vec",
|
||||||
|
/// `cuprate_rpc_types::json::tx::Transaction` should be used
|
||||||
|
/// to create this JSON string in a type-safe manner.
|
||||||
txs_as_json: Vec<String> = default_vec::<String>(), "default_vec",
|
txs_as_json: Vec<String> = default_vec::<String>(), "default_vec",
|
||||||
missed_tx: Vec<String> = default_vec::<String>(), "default_vec",
|
missed_tx: Vec<String> = default_vec::<String>(), "default_vec",
|
||||||
txs: Vec<TxEntry> = default_vec::<TxEntry>(), "default_vec",
|
txs: Vec<TxEntry> = default_vec::<TxEntry>(), "default_vec",
|
||||||
|
|
|
@ -21,28 +21,19 @@ pub struct Block {
|
||||||
pub tx_hashes: Vec<String>,
|
pub tx_hashes: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
/// [`Block::miner_tx`].
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
pub struct MinerTransactionPrefix {
|
|
||||||
pub version: u8,
|
|
||||||
pub unlock_time: u64,
|
|
||||||
pub vin: Vec<Input>,
|
|
||||||
pub vout: Vec<Output>,
|
|
||||||
pub extra: Vec<u8>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum MinerTransaction {
|
pub enum MinerTransaction {
|
||||||
V1 {
|
V1 {
|
||||||
/// This field is flattened.
|
/// This field is [flattened](https://serde.rs/field-attrs.html#flatten).
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
prefix: MinerTransactionPrefix,
|
prefix: MinerTransactionPrefix,
|
||||||
signatures: [(); 0],
|
signatures: [(); 0],
|
||||||
},
|
},
|
||||||
V2 {
|
V2 {
|
||||||
/// This field is flattened.
|
/// This field is [flattened](https://serde.rs/field-attrs.html#flatten).
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
prefix: MinerTransactionPrefix,
|
prefix: MinerTransactionPrefix,
|
||||||
rct_signatures: MinerTransactionRctSignatures,
|
rct_signatures: MinerTransactionRctSignatures,
|
||||||
|
@ -58,18 +49,32 @@ impl Default for MinerTransaction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`MinerTransaction::V1::prefix`] & [`MinerTransaction::V2::prefix`].
|
||||||
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
pub struct MinerTransactionPrefix {
|
||||||
|
pub version: u8,
|
||||||
|
pub unlock_time: u64,
|
||||||
|
pub vin: Vec<Input>,
|
||||||
|
pub vout: Vec<Output>,
|
||||||
|
pub extra: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [`MinerTransaction::V2::rct_signatures`].
|
||||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct MinerTransactionRctSignatures {
|
pub struct MinerTransactionRctSignatures {
|
||||||
pub r#type: u8,
|
pub r#type: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`MinerTransactionPrefix::vin`].
|
||||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Input {
|
pub struct Input {
|
||||||
pub r#gen: Gen,
|
pub r#gen: Gen,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`Input::gen`].
|
||||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Gen {
|
pub struct Gen {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
//! JSON output types.
|
//! JSON output types.
|
||||||
//!
|
//!
|
||||||
//! The same [`Output`] is used in both
|
//! The same [`Output`] is used in both
|
||||||
//! [`crate::json::block::MinerTransaction::vout`] and [`crate::json::tx::Transaction::vout`].
|
//! [`crate::json::block::MinerTransactionPrefix::vout`]
|
||||||
|
//! and [`crate::json::tx::TransactionPrefix::vout`].
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -14,6 +15,7 @@ pub struct Output {
|
||||||
pub target: Target,
|
pub target: Target,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`Output::target`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
@ -30,6 +32,7 @@ impl Default for Target {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`Target::TaggedKey::tagged_key`].
|
||||||
#[derive(Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct TaggedKey {
|
pub struct TaggedKey {
|
||||||
|
|
|
@ -20,13 +20,13 @@ use crate::json::output::Output;
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum Transaction {
|
pub enum Transaction {
|
||||||
V1 {
|
V1 {
|
||||||
/// This field is flattened.
|
/// This field is [flattened](https://serde.rs/field-attrs.html#flatten).
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
prefix: TransactionPrefix,
|
prefix: TransactionPrefix,
|
||||||
signatures: Vec<String>,
|
signatures: Vec<String>,
|
||||||
},
|
},
|
||||||
V2 {
|
V2 {
|
||||||
/// This field is flattened.
|
/// This field is [flattened](https://serde.rs/field-attrs.html#flatten).
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
prefix: TransactionPrefix,
|
prefix: TransactionPrefix,
|
||||||
rct_signatures: RctSignatures,
|
rct_signatures: RctSignatures,
|
||||||
|
@ -34,6 +34,7 @@ pub enum Transaction {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`Transaction::V1::prefix`] & [`Transaction::V2::prefix`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct TransactionPrefix {
|
pub struct TransactionPrefix {
|
||||||
|
@ -44,6 +45,7 @@ pub struct TransactionPrefix {
|
||||||
pub extra: Vec<u8>,
|
pub extra: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`Transaction::V2::rct_signatures`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct RctSignatures {
|
pub struct RctSignatures {
|
||||||
|
@ -53,6 +55,7 @@ pub struct RctSignatures {
|
||||||
pub outPk: Vec<String>,
|
pub outPk: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`Transaction::V2::rctsig_prunable`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct RctSigPrunable {
|
pub struct RctSigPrunable {
|
||||||
|
@ -62,6 +65,7 @@ pub struct RctSigPrunable {
|
||||||
pub pseudoOuts: Vec<String>,
|
pub pseudoOuts: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`RctSigPrunable::bpp`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Bpp {
|
pub struct Bpp {
|
||||||
|
@ -75,6 +79,7 @@ pub struct Bpp {
|
||||||
pub R: Vec<String>,
|
pub R: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`RctSigPrunable::CLSAGs`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Clsag {
|
pub struct Clsag {
|
||||||
|
@ -83,6 +88,7 @@ pub struct Clsag {
|
||||||
pub D: String,
|
pub D: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`RctSignatures::ecdhInfo`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct EcdhInfo {
|
pub struct EcdhInfo {
|
||||||
|
@ -91,12 +97,14 @@ pub struct EcdhInfo {
|
||||||
pub mask: Option<String>,
|
pub mask: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`TransactionPrefix::vin`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Input {
|
pub struct Input {
|
||||||
pub key: Key,
|
pub key: Key,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`Input::key`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Key {
|
pub struct Key {
|
||||||
|
|
Loading…
Reference in a new issue