/get_transactions

This commit is contained in:
hinto.janai 2024-12-11 19:16:34 -05:00
parent b402c82557
commit c3bc9b26ec
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
12 changed files with 401 additions and 182 deletions

View file

@ -1,18 +1,19 @@
//! RPC request handler functions (other JSON endpoints). //! RPC request handler functions (other JSON endpoints).
use std::collections::{HashMap, HashSet}; use std::collections::{BTreeSet, HashMap, HashSet};
use anyhow::{anyhow, Error}; use anyhow::{anyhow, Error};
use cuprate_constants::rpc::{ use cuprate_constants::rpc::{
MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT, RESTRICTED_SPENT_KEY_IMAGES_COUNT, MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT, RESTRICTED_SPENT_KEY_IMAGES_COUNT,
RESTRICTED_TRANSACTIONS_COUNT,
}; };
use cuprate_helper::cast::usize_to_u64; use cuprate_helper::cast::usize_to_u64;
use cuprate_hex::Hex; use cuprate_hex::Hex;
use cuprate_rpc_interface::RpcHandler; use cuprate_rpc_interface::RpcHandler;
use cuprate_rpc_types::{ use cuprate_rpc_types::{
base::{AccessResponseBase, ResponseBase}, base::{AccessResponseBase, ResponseBase},
misc::{KeyImageSpentStatus, Status}, misc::{KeyImageSpentStatus, Status, TxEntry, TxEntryType},
other::{ other::{
GetAltBlocksHashesRequest, GetAltBlocksHashesResponse, GetHeightRequest, GetHeightResponse, GetAltBlocksHashesRequest, GetAltBlocksHashesResponse, GetHeightRequest, GetHeightResponse,
GetLimitRequest, GetLimitResponse, GetNetStatsRequest, GetNetStatsResponse, GetOutsRequest, GetLimitRequest, GetLimitResponse, GetNetStatsRequest, GetNetStatsResponse, GetOutsRequest,
@ -31,15 +32,20 @@ use cuprate_rpc_types::{
UpdateRequest, UpdateResponse, UpdateRequest, UpdateResponse,
}, },
}; };
use cuprate_types::rpc::OutKey; use cuprate_types::{
rpc::{OutKey, PoolInfo, PoolTxInfo},
TxInPool,
};
use monero_serai::transaction::Transaction;
use crate::{ use crate::{
rpc::CupratedRpcHandler, rpc::CupratedRpcHandler,
rpc::{helper, request::blockchain}, rpc::{
helper,
request::{blockchain, blockchain_context, blockchain_manager, txpool},
},
}; };
use super::request::blockchain_manager;
/// Map a [`OtherRequest`] to the function that will lead to a [`OtherResponse`]. /// Map a [`OtherRequest`] to the function that will lead to a [`OtherResponse`].
pub(super) async fn map_request( pub(super) async fn map_request(
state: CupratedRpcHandler, state: CupratedRpcHandler,
@ -112,12 +118,131 @@ async fn get_height(
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L979-L1227> /// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L979-L1227>
async fn get_transactions( async fn get_transactions(
state: CupratedRpcHandler, mut state: CupratedRpcHandler,
request: GetTransactionsRequest, request: GetTransactionsRequest,
) -> Result<GetTransactionsResponse, Error> { ) -> Result<GetTransactionsResponse, Error> {
if state.is_restricted() && request.txs_hashes.len() > RESTRICTED_TRANSACTIONS_COUNT {
return Err(anyhow!(
"Too many transactions requested in restricted mode"
));
}
let requested_txs = request.txs_hashes.into_iter().map(|tx| tx.0).collect();
let (txs_in_blockchain, missed_txs) =
blockchain::transactions(&mut state.blockchain_read, requested_txs).await?;
let missed_tx = missed_txs.clone().into_iter().map(Hex).collect();
// Check the txpool for missed transactions.
let txs_in_pool = if missed_txs.is_empty() {
vec![]
} else {
let include_sensitive_txs = !state.is_restricted();
txpool::txs_by_hash(&mut state.txpool_read, missed_txs, include_sensitive_txs).await?
};
let (txs, txs_as_json) = {
// Prepare the final JSON output.
let len = txs_in_blockchain.len() + txs_in_pool.len();
let mut txs = Vec::with_capacity(len);
let mut txs_as_json = Vec::with_capacity(if request.decode_as_json { len } else { 0 });
// Map all blockchain transactions.
for tx in txs_in_blockchain {
let tx_hash = Hex(tx.tx_hash);
let pruned_as_hex = hex::encode(tx.pruned_blob);
let prunable_as_hex = hex::encode(tx.prunable_blob);
let prunable_hash = Hex(tx.prunable_hash);
let as_json = if request.decode_as_json {
let tx = Transaction::read(&mut tx.tx_blob.as_slice())?;
let json_type = cuprate_types::json::tx::Transaction::from(tx);
let json = serde_json::to_string(&json_type).unwrap();
txs_as_json.push(json.clone());
json
} else {
String::new()
};
let tx_entry_type = TxEntryType::Blockchain {
block_height: tx.block_height,
block_timestamp: tx.block_timestamp,
confirmations: tx.confirmations,
output_indices: tx.output_indices,
in_pool: false,
};
let tx = TxEntry {
as_hex: String::new(),
as_json,
double_spend_seen: false,
tx_hash,
prunable_as_hex,
prunable_hash,
pruned_as_hex,
tx_entry_type,
};
txs.push(tx);
}
// Map all txpool transactions.
for tx_in_pool in txs_in_pool {
let TxInPool {
tx_blob,
tx_hash,
double_spend_seen,
received_timestamp,
relayed,
} = tx_in_pool;
let tx_hash = Hex(tx_hash);
let tx = Transaction::read(&mut tx_blob.as_slice())?;
// TODO: pruned data.
let pruned_as_hex = String::new();
let prunable_as_hex = String::new();
let prunable_hash = Hex([0; 32]);
let as_json = if request.decode_as_json {
let json_type = cuprate_types::json::tx::Transaction::from(tx);
let json = serde_json::to_string(&json_type).unwrap();
txs_as_json.push(json.clone());
json
} else {
String::new()
};
let tx_entry_type = TxEntryType::Pool {
relayed,
received_timestamp,
in_pool: true,
};
let tx = TxEntry {
as_hex: String::new(),
as_json,
double_spend_seen,
tx_hash,
prunable_as_hex,
prunable_hash,
pruned_as_hex,
tx_entry_type,
};
txs.push(tx);
}
(txs, txs_as_json)
};
Ok(GetTransactionsResponse { Ok(GetTransactionsResponse {
base: AccessResponseBase::OK, base: AccessResponseBase::OK,
..todo!() txs_as_hex: vec![],
txs_as_json,
missed_tx,
txs,
}) })
} }

View file

@ -1,7 +1,7 @@
//! Functions to send [`BlockchainReadRequest`]s. //! Functions to send [`BlockchainReadRequest`]s.
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{BTreeSet, HashMap, HashSet},
ops::Range, ops::Range,
}; };
@ -14,7 +14,7 @@ use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
use cuprate_types::{ use cuprate_types::{
blockchain::{BlockchainReadRequest, BlockchainResponse}, blockchain::{BlockchainReadRequest, BlockchainResponse},
rpc::{ChainInfo, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput}, rpc::{ChainInfo, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput},
Chain, ExtendedBlockHeader, OutputOnChain, Chain, ExtendedBlockHeader, OutputOnChain, TxInBlockchain,
}; };
/// [`BlockchainReadRequest::Block`]. /// [`BlockchainReadRequest::Block`].
@ -375,3 +375,20 @@ pub(crate) async fn alt_chain_count(
Ok(usize_to_u64(count)) Ok(usize_to_u64(count))
} }
/// [`BlockchainReadRequest::Transactions`].
pub(crate) async fn transactions(
blockchain_read: &mut BlockchainReadHandle,
tx_hashes: BTreeSet<[u8; 32]>,
) -> Result<(Vec<TxInBlockchain>, Vec<[u8; 32]>), Error> {
let BlockchainResponse::Transactions { txs, missed_txs } = blockchain_read
.ready()
.await?
.call(BlockchainReadRequest::Transactions { tx_hashes })
.await?
else {
unreachable!();
};
Ok((txs, missed_txs))
}

View file

@ -13,7 +13,10 @@ use cuprate_txpool::{
}, },
TxEntry, TxEntry,
}; };
use cuprate_types::rpc::{PoolInfo, PoolInfoFull, PoolInfoIncremental, PoolTxInfo}; use cuprate_types::{
rpc::{PoolInfo, PoolInfoFull, PoolInfoIncremental, PoolTxInfo},
TxInPool,
};
// FIXME: use `anyhow::Error` over `tower::BoxError` in txpool. // FIXME: use `anyhow::Error` over `tower::BoxError` in txpool.
@ -60,8 +63,8 @@ pub(crate) async fn pool_info(
include_sensitive_txs: bool, include_sensitive_txs: bool,
max_tx_count: usize, max_tx_count: usize,
start_time: Option<NonZero<usize>>, start_time: Option<NonZero<usize>>,
) -> Result<Vec<PoolInfo>, Error> { ) -> Result<PoolInfo, Error> {
let TxpoolReadResponse::PoolInfo(vec) = txpool_read let TxpoolReadResponse::PoolInfo(pool_info) = txpool_read
.ready() .ready()
.await .await
.map_err(|e| anyhow!(e))? .map_err(|e| anyhow!(e))?
@ -76,7 +79,30 @@ pub(crate) async fn pool_info(
unreachable!(); unreachable!();
}; };
Ok(vec) Ok(pool_info)
}
/// TODO
pub(crate) async fn txs_by_hash(
txpool_read: &mut TxpoolReadHandle,
tx_hashes: Vec<[u8; 32]>,
include_sensitive_txs: bool,
) -> Result<Vec<TxInPool>, Error> {
let TxpoolReadResponse::TxsByHash(txs_in_pool) = txpool_read
.ready()
.await
.map_err(|e| anyhow!(e))?
.call(TxpoolReadRequest::TxsByHash {
tx_hashes,
include_sensitive_txs,
})
.await
.map_err(|e| anyhow!(e))?
else {
unreachable!();
};
Ok(txs_in_pool)
} }
/// TODO /// TODO

View file

@ -25,7 +25,7 @@ pub use distribution::{Distribution, DistributionCompressedBinary, DistributionU
pub use key_image_spent_status::KeyImageSpentStatus; pub use key_image_spent_status::KeyImageSpentStatus;
pub use requested_info::RequestedInfo; pub use requested_info::RequestedInfo;
pub use status::Status; pub use status::Status;
pub use tx_entry::TxEntry; pub use tx_entry::{TxEntry, TxEntryType};
pub use types::{ pub use types::{
BlockHeader, ChainInfo, ConnectionInfo, GetBan, GetOutputsOut, HistogramEntry, OutKeyBin, BlockHeader, ChainInfo, ConnectionInfo, GetBan, GetOutputsOut, HistogramEntry, OutKeyBin,
SetBan, Span, SpentKeyImageInfo, SyncInfoPeer, TxInfo, SetBan, Span, SpentKeyImageInfo, SyncInfoPeer, TxInfo,

View file

@ -11,6 +11,8 @@ use cuprate_epee_encoding::{
EpeeObject, EpeeObjectBuilder, EpeeObject, EpeeObjectBuilder,
}; };
use cuprate_hex::Hex;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use crate::serde::{serde_false, serde_true}; use crate::serde::{serde_false, serde_true};
@ -28,100 +30,63 @@ use crate::serde::{serde_false, serde_true};
/// ///
/// It is only implemented to satisfy the RPC type generator /// It is only implemented to satisfy the RPC type generator
/// macro, which requires all objects to be serde + epee. /// macro, which requires all objects to be serde + epee.
/// #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
/// # Example #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
/// ```rust pub struct TxEntry {
/// use cuprate_rpc_types::misc::*; /// `cuprate_types::json::tx::Transaction` should be used
/// use serde_json::{json, from_value}; /// to create this JSON string in a type-safe manner.
/// pub as_json: String,
/// let json = json!({
/// "as_hex": String::default(), pub as_hex: String,
/// "as_json": String::default(), pub double_spend_seen: bool,
/// "block_height": u64::default(), pub tx_hash: Hex<32>,
/// "block_timestamp": u64::default(), pub prunable_as_hex: String,
/// "confirmations": u64::default(), pub prunable_hash: Hex<32>,
/// "double_spend_seen": bool::default(), pub pruned_as_hex: String,
/// "output_indices": Vec::<u64>::default(),
/// "prunable_as_hex": String::default(), #[cfg_attr(feature = "serde", serde(flatten))]
/// "prunable_hash": String::default(), pub tx_entry_type: TxEntryType,
/// "pruned_as_hex": String::default(), }
/// "tx_hash": String::default(),
/// "in_pool": bool::default(), /// Different fields in [`TxEntry`] variants.
/// });
/// let tx_entry = from_value::<TxEntry>(json).unwrap();
/// assert!(matches!(tx_entry, TxEntry::InPool { .. }));
///
/// let json = json!({
/// "as_hex": String::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(),
/// "relayed": bool::default(),
/// "tx_hash": String::default(),
/// "in_pool": bool::default(),
/// });
/// let tx_entry = from_value::<TxEntry>(json).unwrap();
/// assert!(matches!(tx_entry, TxEntry::NotInPool { .. }));
/// ```
#[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))]
#[cfg_attr(feature = "serde", serde(untagged))] #[cfg_attr(feature = "serde", serde(untagged))]
pub enum TxEntry { pub enum TxEntryType {
/// This entry exists in the transaction pool. /// This transaction exists in the blockchain.
InPool { Blockchain {
/// This field is [flattened](https://serde.rs/field-attrs.html#flatten).
#[cfg_attr(feature = "serde", serde(flatten))]
prefix: TxEntryPrefix,
block_height: u64, block_height: u64,
block_timestamp: u64, block_timestamp: u64,
confirmations: u64, confirmations: u64,
output_indices: Vec<u64>, output_indices: Vec<u64>,
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_true"))]
/// Will always be serialized as `true`. /// Will always be serialized as `false`.
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_false"))]
in_pool: bool, in_pool: bool,
}, },
/// This entry _does not_ exist in the transaction pool.
NotInPool { /// This transaction exists in the transaction pool.
/// This field is [flattened](https://serde.rs/field-attrs.html#flatten). Pool {
#[cfg_attr(feature = "serde", serde(flatten))]
prefix: TxEntryPrefix,
received_timestamp: u64, received_timestamp: u64,
relayed: bool, relayed: bool,
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_false"))]
/// Will always be serialized as `false`. /// Will always be serialized as `true`.
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_true"))]
in_pool: bool, in_pool: bool,
}, },
} }
impl Default for TxEntry { impl Default for TxEntryType {
fn default() -> Self { fn default() -> Self {
Self::NotInPool { Self::Blockchain {
prefix: Default::default(), block_height: Default::default(),
received_timestamp: u64::default(), block_timestamp: Default::default(),
relayed: bool::default(), confirmations: Default::default(),
in_pool: false, output_indices: Default::default(),
in_pool: Default::default(),
} }
} }
} }
/// 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 () {

File diff suppressed because one or more lines are too long

View file

@ -11,7 +11,7 @@
//---------------------------------------------------------------------------------------------------- Import //---------------------------------------------------------------------------------------------------- Import
use std::{ use std::{
cmp::min, cmp::min,
collections::{HashMap, HashSet}, collections::{BTreeSet, HashMap, HashSet},
sync::Arc, sync::Arc,
}; };
@ -134,6 +134,7 @@ fn map_request(
R::CoinbaseTxSum { height, count } => coinbase_tx_sum(env, height, count), R::CoinbaseTxSum { height, count } => coinbase_tx_sum(env, height, count),
R::AltChains => alt_chains(env), R::AltChains => alt_chains(env),
R::AltChainCount => alt_chain_count(env), R::AltChainCount => alt_chain_count(env),
R::Transactions { tx_hashes } => transactions(env, tx_hashes),
} }
/* SOMEDAY: post-request handling, run some code for each request? */ /* SOMEDAY: post-request handling, run some code for each request? */
@ -783,3 +784,11 @@ fn alt_chains(env: &ConcreteEnv) -> ResponseResult {
fn alt_chain_count(env: &ConcreteEnv) -> ResponseResult { fn alt_chain_count(env: &ConcreteEnv) -> ResponseResult {
Ok(BlockchainResponse::AltChainCount(todo!())) Ok(BlockchainResponse::AltChainCount(todo!()))
} }
/// [`BlockchainReadRequest::Transactions`]
fn transactions(env: &ConcreteEnv, tx_hashes: BTreeSet<[u8; 32]>) -> ResponseResult {
Ok(BlockchainResponse::Transactions {
txs: todo!(),
missed_txs: todo!(),
})
}

View file

@ -5,9 +5,10 @@ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
num::NonZero, num::NonZero,
sync::Arc, sync::Arc,
time::Instant,
}; };
use cuprate_types::{rpc::PoolInfo, TransactionVerificationData}; use cuprate_types::{rpc::PoolInfo, TransactionVerificationData, TxInPool};
use crate::{ use crate::{
tx::TxEntry, tx::TxEntry,
@ -52,6 +53,11 @@ pub enum TxpoolReadRequest {
/// TODO /// TODO
start_time: Option<NonZero<usize>>, start_time: Option<NonZero<usize>>,
}, },
TxsByHash {
tx_hashes: Vec<[u8; 32]>,
include_sensitive_txs: bool,
},
} }
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse //---------------------------------------------------------------------------------------------------- TxpoolReadResponse
@ -93,7 +99,10 @@ pub enum TxpoolReadResponse {
Size(usize), Size(usize),
/// Response to [`TxpoolReadRequest::PoolInfo`]. /// Response to [`TxpoolReadRequest::PoolInfo`].
PoolInfo(Vec<PoolInfo>), PoolInfo(PoolInfo),
/// Response to [`TxpoolReadRequest::TxsByHash`].
TxsByHash(Vec<TxInPool>),
} }
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest

View file

@ -2,6 +2,7 @@
unreachable_code, unreachable_code,
unused_variables, unused_variables,
clippy::unnecessary_wraps, clippy::unnecessary_wraps,
clippy::needless_pass_by_value,
reason = "TODO: finish implementing the signatures from <https://github.com/Cuprate/cuprate/pull/297>" reason = "TODO: finish implementing the signatures from <https://github.com/Cuprate/cuprate/pull/297>"
)] )]
use std::{ use std::{
@ -79,7 +80,11 @@ fn map_request(
include_sensitive_txs, include_sensitive_txs,
max_tx_count, max_tx_count,
start_time, start_time,
} => pool_info(include_sensitive_txs, max_tx_count, start_time), } => pool_info(env, include_sensitive_txs, max_tx_count, start_time),
TxpoolReadRequest::TxsByHash {
tx_hashes,
include_sensitive_txs,
} => txs_by_hash(env, tx_hashes, include_sensitive_txs),
} }
} }
@ -215,9 +220,19 @@ fn size(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
/// [`TxpoolReadRequest::PoolInfo`]. /// [`TxpoolReadRequest::PoolInfo`].
fn pool_info( fn pool_info(
env: &ConcreteEnv,
include_sensitive_txs: bool, include_sensitive_txs: bool,
max_tx_count: usize, max_tx_count: usize,
start_time: Option<NonZero<usize>>, start_time: Option<NonZero<usize>>,
) -> ReadResponseResult { ) -> ReadResponseResult {
Ok(TxpoolReadResponse::PoolInfo(todo!())) Ok(TxpoolReadResponse::PoolInfo(todo!()))
} }
/// [`TxpoolReadRequest::TxsByHash`].
fn txs_by_hash(
env: &ConcreteEnv,
tx_hashes: Vec<[u8; 32]>,
include_sensitive_txs: bool,
) -> ReadResponseResult {
Ok(TxpoolReadResponse::TxsByHash(todo!()))
}

View file

@ -4,7 +4,7 @@
//! responses are also tested in Cuprate's blockchain database crate. //! responses are also tested in Cuprate's blockchain database crate.
//---------------------------------------------------------------------------------------------------- Import //---------------------------------------------------------------------------------------------------- Import
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{BTreeSet, HashMap, HashSet},
ops::Range, ops::Range,
}; };
@ -12,7 +12,7 @@ use monero_serai::block::Block;
use crate::{ use crate::{
types::{Chain, ExtendedBlockHeader, OutputOnChain, TxsInBlock, VerifiedBlockInformation}, types::{Chain, ExtendedBlockHeader, OutputOnChain, TxsInBlock, VerifiedBlockInformation},
AltBlockInformation, BlockCompleteEntry, ChainId, AltBlockInformation, BlockCompleteEntry, ChainId, TxInBlockchain,
}; };
use crate::rpc::{ChainInfo, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput}; use crate::rpc::{ChainInfo, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput};
@ -161,6 +161,9 @@ pub enum BlockchainReadRequest {
/// Get the amount of alternative chains that exist. /// Get the amount of alternative chains that exist.
AltChainCount, AltChainCount,
/// TODO
Transactions { tx_hashes: BTreeSet<[u8; 32]> },
} }
//---------------------------------------------------------------------------------------------------- WriteRequest //---------------------------------------------------------------------------------------------------- WriteRequest
@ -348,6 +351,14 @@ pub enum BlockchainResponse {
/// Response to [`BlockchainReadRequest::AltChainCount`]. /// Response to [`BlockchainReadRequest::AltChainCount`].
AltChainCount(usize), AltChainCount(usize),
/// Response to [`BlockchainReadRequest::Transactions`].
Transactions {
/// The transaction blobs found.
txs: Vec<TxInBlockchain>,
/// The hashes of any transactions that could not be found.
missed_txs: Vec<[u8; 32]>,
},
//------------------------------------------------------ Writes //------------------------------------------------------ Writes
/// A generic Ok response to indicate a request was successfully handled. /// A generic Ok response to indicate a request was successfully handled.
/// ///

View file

@ -25,7 +25,7 @@ pub use transaction_verification_data::{
}; };
pub use types::{ pub use types::{
AltBlockInformation, BlockTemplate, Chain, ChainId, ExtendedBlockHeader, OutputOnChain, AltBlockInformation, BlockTemplate, Chain, ChainId, ExtendedBlockHeader, OutputOnChain,
TxsInBlock, VerifiedBlockInformation, VerifiedTransactionInformation, TxInBlockchain, TxInPool, TxsInBlock, VerifiedBlockInformation, VerifiedTransactionInformation,
}; };
//---------------------------------------------------------------------------------------------------- Feature-gated //---------------------------------------------------------------------------------------------------- Feature-gated

View file

@ -167,6 +167,30 @@ pub struct BlockTemplate {
pub next_seed_hash: [u8; 32], pub next_seed_hash: [u8; 32],
} }
/// TODO
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TxInBlockchain {
pub block_height: u64,
pub block_timestamp: u64,
pub confirmations: u64,
pub output_indices: Vec<u64>,
pub tx_hash: [u8; 32],
pub tx_blob: Vec<u8>,
pub pruned_blob: Vec<u8>,
pub prunable_blob: Vec<u8>,
pub prunable_hash: [u8; 32],
}
/// TODO
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TxInPool {
pub tx_blob: Vec<u8>,
pub tx_hash: [u8; 32],
pub double_spend_seen: bool,
pub received_timestamp: u64,
pub relayed: bool,
}
//---------------------------------------------------------------------------------------------------- Tests //---------------------------------------------------------------------------------------------------- Tests
#[cfg(test)] #[cfg(test)]
mod test { mod test {