mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-22 19:49:33 +00:00
Compare commits
2 commits
0b50091b5d
...
568a276b7f
Author | SHA1 | Date | |
---|---|---|---|
|
568a276b7f | ||
|
2104bb0e17 |
43 changed files with 1482 additions and 830 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1067,8 +1067,11 @@ version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cuprate-epee-encoding",
|
"cuprate-epee-encoding",
|
||||||
"cuprate-fixed-bytes",
|
"cuprate-fixed-bytes",
|
||||||
|
"cuprate-helper",
|
||||||
|
"cuprate-p2p-core",
|
||||||
"cuprate-test-utils",
|
"cuprate-test-utils",
|
||||||
"cuprate-types",
|
"cuprate-types",
|
||||||
|
"hex",
|
||||||
"paste",
|
"paste",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -1127,6 +1130,7 @@ name = "cuprate-types"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"cfg-if",
|
||||||
"cuprate-epee-encoding",
|
"cuprate-epee-encoding",
|
||||||
"cuprate-fixed-bytes",
|
"cuprate-fixed-bytes",
|
||||||
"cuprate-helper",
|
"cuprate-helper",
|
||||||
|
|
|
@ -31,7 +31,7 @@ cuprate-txpool = { workspace = true }
|
||||||
cuprate-database = { workspace = true, features = ["serde"] }
|
cuprate-database = { workspace = true, features = ["serde"] }
|
||||||
cuprate-pruning = { workspace = true }
|
cuprate-pruning = { workspace = true }
|
||||||
cuprate-test-utils = { workspace = true }
|
cuprate-test-utils = { workspace = true }
|
||||||
cuprate-types = { workspace = true }
|
cuprate-types = { workspace = true, features = ["json"] }
|
||||||
cuprate-json-rpc = { workspace = true }
|
cuprate-json-rpc = { workspace = true }
|
||||||
cuprate-rpc-interface = { workspace = true }
|
cuprate-rpc-interface = { workspace = true }
|
||||||
cuprate-rpc-types = { workspace = true }
|
cuprate-rpc-types = { workspace = true }
|
||||||
|
|
|
@ -15,7 +15,7 @@ use cuprate_rpc_types::{
|
||||||
json::{GetOutputDistributionRequest, GetOutputDistributionResponse},
|
json::{GetOutputDistributionRequest, GetOutputDistributionResponse},
|
||||||
misc::RequestedInfo,
|
misc::RequestedInfo,
|
||||||
};
|
};
|
||||||
use cuprate_types::BlockCompleteEntry;
|
use cuprate_types::{rpc::PoolInfoExtent, BlockCompleteEntry};
|
||||||
|
|
||||||
use crate::rpc::{helper, request::blockchain, CupratedRpcHandler};
|
use crate::rpc::{helper, request::blockchain, CupratedRpcHandler};
|
||||||
|
|
||||||
|
@ -61,14 +61,44 @@ async fn get_blocks(
|
||||||
RequestedInfo::PoolOnly => (false, true),
|
RequestedInfo::PoolOnly => (false, true),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let pool_info_extent = PoolInfoExtent::None;
|
||||||
|
|
||||||
if get_pool {
|
if get_pool {
|
||||||
|
let allow_sensitive = !state.is_restricted();
|
||||||
let max_tx_count = if state.is_restricted() {
|
let max_tx_count = if state.is_restricted() {
|
||||||
RESTRICTED_TRANSACTIONS_COUNT
|
RESTRICTED_TRANSACTIONS_COUNT
|
||||||
} else {
|
} else {
|
||||||
usize::MAX
|
usize::MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
todo!();
|
// bool incremental;
|
||||||
|
// std::vector<std::pair<crypto::hash, tx_memory_pool::tx_details>> added_pool_txs;
|
||||||
|
// bool success = m_core.get_pool_info((time_t)req.pool_info_since, allow_sensitive, max_tx_count, added_pool_txs, res.remaining_added_pool_txids, res.removed_pool_txids, incremental);
|
||||||
|
// if (success)
|
||||||
|
// {
|
||||||
|
// res.added_pool_txs.clear();
|
||||||
|
// if (m_rpc_payment)
|
||||||
|
// {
|
||||||
|
// CHECK_PAYMENT_SAME_TS(req, res, added_pool_txs.size() * COST_PER_TX + (res.remaining_added_pool_txids.size() + res.removed_pool_txids.size()) * COST_PER_POOL_HASH);
|
||||||
|
// }
|
||||||
|
// for (const auto &added_pool_tx: added_pool_txs)
|
||||||
|
// {
|
||||||
|
// COMMAND_RPC_GET_BLOCKS_FAST::pool_tx_info info;
|
||||||
|
// info.tx_hash = added_pool_tx.first;
|
||||||
|
// std::stringstream oss;
|
||||||
|
// binary_archive<true> ar(oss);
|
||||||
|
// bool r = req.prune
|
||||||
|
// ? const_cast<cryptonote::transaction&>(added_pool_tx.second.tx).serialize_base(ar)
|
||||||
|
// : ::serialization::serialize(ar, const_cast<cryptonote::transaction&>(added_pool_tx.second.tx));
|
||||||
|
// if (!r)
|
||||||
|
// {
|
||||||
|
// res.status = "Failed to serialize transaction";
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// info.tx_blob = oss.str();
|
||||||
|
// info.double_spend_seen = added_pool_tx.second.double_spend_seen;
|
||||||
|
// res.added_pool_txs.push_back(std::move(info));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if get_blocks {
|
if get_blocks {
|
||||||
|
@ -79,11 +109,15 @@ async fn get_blocks(
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok(GetBlocksResponse {
|
Ok(GetBlocksResponse {
|
||||||
// base: ResponseBase::OK,
|
base: AccessResponseBase::OK,
|
||||||
// ..todo!()
|
blocks: todo!(),
|
||||||
// })
|
start_height: todo!(),
|
||||||
Ok(todo!())
|
current_height: todo!(),
|
||||||
|
output_indices: todo!(),
|
||||||
|
daemon_time: todo!(),
|
||||||
|
pool_info: todo!(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L817-L857>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L817-L857>
|
||||||
|
|
|
@ -65,9 +65,9 @@ pub(super) async fn block_header(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
hex::encode(pow_hash)
|
pow_hash
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
[0; 32]
|
||||||
};
|
};
|
||||||
|
|
||||||
let block_weight = usize_to_u64(header.block_weight);
|
let block_weight = usize_to_u64(header.block_weight);
|
||||||
|
@ -86,30 +86,28 @@ pub(super) async fn block_header(
|
||||||
.map(|o| o.amount.expect("coinbase is transparent"))
|
.map(|o| o.amount.expect("coinbase is transparent"))
|
||||||
.sum::<u64>();
|
.sum::<u64>();
|
||||||
|
|
||||||
Ok(BlockHeader {
|
Ok(cuprate_types::rpc::BlockHeader {
|
||||||
block_size: block_weight,
|
|
||||||
block_weight,
|
block_weight,
|
||||||
cumulative_difficulty_top64,
|
cumulative_difficulty_top64,
|
||||||
cumulative_difficulty,
|
cumulative_difficulty,
|
||||||
depth,
|
depth,
|
||||||
difficulty_top64,
|
difficulty_top64,
|
||||||
difficulty,
|
difficulty,
|
||||||
hash: hex::encode(block.hash()),
|
hash: block.hash(),
|
||||||
height,
|
height,
|
||||||
long_term_weight: usize_to_u64(header.long_term_weight),
|
long_term_weight: usize_to_u64(header.long_term_weight),
|
||||||
major_version: header.version.as_u8(),
|
major_version: header.version,
|
||||||
miner_tx_hash: hex::encode(block.miner_transaction.hash()),
|
miner_tx_hash: block.miner_transaction.hash(),
|
||||||
minor_version: header.vote,
|
minor_version: header.vote,
|
||||||
nonce: block.header.nonce,
|
nonce: block.header.nonce,
|
||||||
num_txes: usize_to_u64(block.transactions.len()),
|
num_txes: usize_to_u64(block.transactions.len()),
|
||||||
orphan_status,
|
orphan_status,
|
||||||
pow_hash,
|
pow_hash,
|
||||||
prev_hash: hex::encode(block.header.previous),
|
prev_hash: block.header.previous,
|
||||||
reward,
|
reward,
|
||||||
timestamp: block.header.timestamp,
|
timestamp: block.header.timestamp,
|
||||||
wide_cumulative_difficulty: hex::encode(u128::to_le_bytes(header.cumulative_difficulty)),
|
}
|
||||||
wide_difficulty,
|
.into())
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as [`block_header`] but with the block's hash.
|
/// Same as [`block_header`] but with the block's hash.
|
||||||
|
|
|
@ -47,13 +47,13 @@ use cuprate_rpc_types::{
|
||||||
SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest,
|
SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest,
|
||||||
SyncInfoResponse,
|
SyncInfoResponse,
|
||||||
},
|
},
|
||||||
misc::{
|
misc::{BlockHeader, ChainInfo, Distribution, GetBan, HistogramEntry, Status, SyncInfoPeer},
|
||||||
AuxPow, BlockHeader, ChainInfo, Distribution, GetBan, GetMinerDataTxBacklogEntry,
|
|
||||||
HardforkEntry, HistogramEntry, Status, SyncInfoPeer, TxBacklogEntry,
|
|
||||||
},
|
|
||||||
CORE_RPC_VERSION,
|
CORE_RPC_VERSION,
|
||||||
};
|
};
|
||||||
use cuprate_types::HardFork;
|
use cuprate_types::{
|
||||||
|
rpc::{AuxPow, CoinbaseTxSum, GetMinerDataTxBacklogEntry, HardforkEntry, TxBacklogEntry},
|
||||||
|
HardFork,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::VERSION_BUILD,
|
constants::VERSION_BUILD,
|
||||||
|
@ -669,7 +669,7 @@ async fn get_output_histogram(
|
||||||
mut state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetOutputHistogramRequest,
|
request: GetOutputHistogramRequest,
|
||||||
) -> Result<GetOutputHistogramResponse, Error> {
|
) -> Result<GetOutputHistogramResponse, Error> {
|
||||||
let input = cuprate_types::OutputHistogramInput {
|
let input = cuprate_types::rpc::OutputHistogramInput {
|
||||||
amounts: request.amounts,
|
amounts: request.amounts,
|
||||||
min_count: request.min_count,
|
min_count: request.min_count,
|
||||||
max_count: request.max_count,
|
max_count: request.max_count,
|
||||||
|
@ -699,17 +699,17 @@ async fn get_coinbase_tx_sum(
|
||||||
mut state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetCoinbaseTxSumRequest,
|
request: GetCoinbaseTxSumRequest,
|
||||||
) -> Result<GetCoinbaseTxSumResponse, Error> {
|
) -> Result<GetCoinbaseTxSumResponse, Error> {
|
||||||
let sum =
|
let CoinbaseTxSum {
|
||||||
blockchain::coinbase_tx_sum(&mut state.blockchain_read, request.height, request.count)
|
emission_amount_top64,
|
||||||
.await?;
|
emission_amount,
|
||||||
|
fee_amount_top64,
|
||||||
|
fee_amount,
|
||||||
|
} = blockchain::coinbase_tx_sum(&mut state.blockchain_read, request.height, request.count)
|
||||||
|
.await?;
|
||||||
|
|
||||||
// Formats `u128` as hexadecimal strings.
|
// Formats `u128` as hexadecimal strings.
|
||||||
let wide_emission_amount = format!("{:#x}", sum.fee_amount);
|
let wide_emission_amount = format!("{fee_amount:#x}");
|
||||||
let wide_fee_amount = format!("{:#x}", sum.emission_amount);
|
let wide_fee_amount = format!("{emission_amount:#x}");
|
||||||
|
|
||||||
let (emission_amount, emission_amount_top64) =
|
|
||||||
split_u128_into_low_high_bits(sum.emission_amount);
|
|
||||||
let (fee_amount, fee_amount_top64) = split_u128_into_low_high_bits(sum.fee_amount);
|
|
||||||
|
|
||||||
Ok(GetCoinbaseTxSumResponse {
|
Ok(GetCoinbaseTxSumResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: AccessResponseBase::OK,
|
||||||
|
@ -738,7 +738,8 @@ async fn get_version(
|
||||||
{
|
{
|
||||||
let entry = HardforkEntry {
|
let entry = HardforkEntry {
|
||||||
height: hf.earliest_height,
|
height: hf.earliest_height,
|
||||||
hf_version: hf.version,
|
hf_version: HardFork::from_version(hf.version)
|
||||||
|
.expect("blockchain context should not be responding with invalid hardforks"),
|
||||||
};
|
};
|
||||||
|
|
||||||
hard_forks.push(entry);
|
hard_forks.push(entry);
|
||||||
|
@ -780,21 +781,7 @@ async fn get_alternate_chains(
|
||||||
let chains = blockchain::alt_chains(&mut state.blockchain_read)
|
let chains = blockchain::alt_chains(&mut state.blockchain_read)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|info| {
|
.map(Into::into)
|
||||||
let block_hashes = info.block_hashes.into_iter().map(hex::encode).collect();
|
|
||||||
let (difficulty, difficulty_top64) = split_u128_into_low_high_bits(info.difficulty);
|
|
||||||
|
|
||||||
ChainInfo {
|
|
||||||
block_hash: hex::encode(info.block_hash),
|
|
||||||
block_hashes,
|
|
||||||
difficulty,
|
|
||||||
difficulty_top64,
|
|
||||||
height: info.height,
|
|
||||||
length: info.length,
|
|
||||||
main_chain_parent_block: hex::encode(info.main_chain_parent_block),
|
|
||||||
wide_difficulty: hex::encode(u128::to_ne_bytes(info.difficulty)),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(GetAlternateChainsResponse {
|
Ok(GetAlternateChainsResponse {
|
||||||
|
@ -1036,19 +1023,11 @@ fn add_aux_pow_inner(
|
||||||
return Err(anyhow!("Empty `aux_pow` vector"));
|
return Err(anyhow!("Empty `aux_pow` vector"));
|
||||||
};
|
};
|
||||||
|
|
||||||
let aux_pow = request
|
|
||||||
.aux_pow
|
|
||||||
.into_iter()
|
|
||||||
.map(|aux| {
|
|
||||||
let id = helper::hex_to_hash(aux.id)?;
|
|
||||||
let hash = helper::hex_to_hash(aux.hash)?;
|
|
||||||
Ok(cuprate_types::AuxPow { id, hash })
|
|
||||||
})
|
|
||||||
.collect::<Result<Box<[_]>, Error>>()?;
|
|
||||||
// Some of the code below requires that the
|
// Some of the code below requires that the
|
||||||
// `.len()` of certain containers are the same.
|
// `.len()` of certain containers are the same.
|
||||||
// Boxed slices are used over `Vec` to slightly
|
// Boxed slices are used over `Vec` to slightly
|
||||||
// safe-guard against accidently pushing to it.
|
// safe-guard against accidently pushing to it.
|
||||||
|
let aux_pow = request.aux_pow.into_boxed_slice();
|
||||||
|
|
||||||
// TODO: why is this here? it does nothing:
|
// TODO: why is this here? it does nothing:
|
||||||
// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2110-L2112>
|
// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2110-L2112>
|
||||||
|
@ -1058,7 +1037,7 @@ fn add_aux_pow_inner(
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn find_nonce(
|
fn find_nonce(
|
||||||
aux_pow: &[cuprate_types::AuxPow],
|
aux_pow: &[AuxPow],
|
||||||
non_zero_len: NonZero<usize>,
|
non_zero_len: NonZero<usize>,
|
||||||
aux_pow_len: usize,
|
aux_pow_len: usize,
|
||||||
) -> Result<(u32, Box<[u32]>), Error> {
|
) -> Result<(u32, Box<[u32]>), Error> {
|
||||||
|
@ -1219,11 +1198,8 @@ fn add_aux_pow_inner(
|
||||||
let blockhashing_blob = hex::encode(blockhashing_blob);
|
let blockhashing_blob = hex::encode(blockhashing_blob);
|
||||||
let merkle_root = hex::encode(merkle_root);
|
let merkle_root = hex::encode(merkle_root);
|
||||||
let aux_pow = IntoIterator::into_iter(aux_pow) // must be explicit due to `boxed_slice_into_iter`
|
let aux_pow = IntoIterator::into_iter(aux_pow) // must be explicit due to `boxed_slice_into_iter`
|
||||||
.map(|aux| AuxPow {
|
.map(Into::into)
|
||||||
id: hex::encode(aux.id),
|
.collect::<Vec<cuprate_rpc_types::misc::AuxPow>>();
|
||||||
hash: hex::encode(aux.hash),
|
|
||||||
})
|
|
||||||
.collect::<Vec<AuxPow>>();
|
|
||||||
|
|
||||||
Ok(AddAuxPowResponse {
|
Ok(AddAuxPowResponse {
|
||||||
base: ResponseBase::OK,
|
base: ResponseBase::OK,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use cuprate_helper::cast::usize_to_u64;
|
||||||
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, OutKey, Status},
|
misc::{KeyImageSpentStatus, Status},
|
||||||
other::{
|
other::{
|
||||||
GetAltBlocksHashesRequest, GetAltBlocksHashesResponse, GetHeightRequest, GetHeightResponse,
|
GetAltBlocksHashesRequest, GetAltBlocksHashesResponse, GetHeightRequest, GetHeightResponse,
|
||||||
GetLimitRequest, GetLimitResponse, GetNetStatsRequest, GetNetStatsResponse, GetOutsRequest,
|
GetLimitRequest, GetLimitResponse, GetNetStatsRequest, GetNetStatsResponse, GetOutsRequest,
|
||||||
|
@ -30,6 +30,7 @@ use cuprate_rpc_types::{
|
||||||
UpdateRequest, UpdateResponse,
|
UpdateRequest, UpdateResponse,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use cuprate_types::rpc::OutKey;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
rpc::CupratedRpcHandler,
|
rpc::CupratedRpcHandler,
|
||||||
|
|
|
@ -13,8 +13,8 @@ use cuprate_blockchain::service::BlockchainReadHandle;
|
||||||
use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
|
use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
|
||||||
use cuprate_types::{
|
use cuprate_types::{
|
||||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||||
Chain, ChainInfo, CoinbaseTxSum, ExtendedBlockHeader, OutputHistogramEntry,
|
rpc::{ChainInfo, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput},
|
||||||
OutputHistogramInput, OutputOnChain,
|
Chain, ExtendedBlockHeader, OutputOnChain,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// [`BlockchainReadRequest::Block`].
|
/// [`BlockchainReadRequest::Block`].
|
||||||
|
|
|
@ -8,7 +8,10 @@ use cuprate_consensus_context::{
|
||||||
BlockChainContext, BlockChainContextRequest, BlockChainContextResponse,
|
BlockChainContext, BlockChainContextRequest, BlockChainContextResponse,
|
||||||
BlockChainContextService,
|
BlockChainContextService,
|
||||||
};
|
};
|
||||||
use cuprate_types::{FeeEstimate, HardFork, HardForkInfo};
|
use cuprate_types::{
|
||||||
|
rpc::{FeeEstimate, HardForkInfo},
|
||||||
|
HardFork,
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME: use `anyhow::Error` over `tower::BoxError` in blockchain context.
|
// FIXME: use `anyhow::Error` over `tower::BoxError` in blockchain context.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! Functions to send [`TxpoolReadRequest`]s.
|
//! Functions to send [`TxpoolReadRequest`]s.
|
||||||
|
|
||||||
use std::convert::Infallible;
|
use std::{convert::Infallible, num::NonZero};
|
||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
@ -13,6 +13,7 @@ use cuprate_txpool::{
|
||||||
},
|
},
|
||||||
TxEntry,
|
TxEntry,
|
||||||
};
|
};
|
||||||
|
use cuprate_types::rpc::{PoolInfo, PoolInfoFull, PoolInfoIncremental, PoolTxInfo};
|
||||||
|
|
||||||
// FIXME: use `anyhow::Error` over `tower::BoxError` in txpool.
|
// FIXME: use `anyhow::Error` over `tower::BoxError` in txpool.
|
||||||
|
|
||||||
|
@ -53,6 +54,31 @@ pub(crate) async fn size(
|
||||||
Ok(usize_to_u64(size))
|
Ok(usize_to_u64(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
pub(crate) async fn pool_info(
|
||||||
|
txpool_read: &mut TxpoolReadHandle,
|
||||||
|
include_sensitive_txs: bool,
|
||||||
|
max_tx_count: usize,
|
||||||
|
start_time: Option<NonZero<usize>>,
|
||||||
|
) -> Result<Vec<PoolInfo>, Error> {
|
||||||
|
let TxpoolReadResponse::PoolInfo(vec) = txpool_read
|
||||||
|
.ready()
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!(e))?
|
||||||
|
.call(TxpoolReadRequest::PoolInfo {
|
||||||
|
include_sensitive_txs,
|
||||||
|
max_tx_count,
|
||||||
|
start_time,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!(e))?
|
||||||
|
else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(vec)
|
||||||
|
}
|
||||||
|
|
||||||
/// TODO
|
/// TODO
|
||||||
pub(crate) async fn flush(
|
pub(crate) async fn flush(
|
||||||
txpool_manager: &mut Infallible,
|
txpool_manager: &mut Infallible,
|
||||||
|
|
|
@ -36,7 +36,10 @@ mod alt_chains;
|
||||||
mod task;
|
mod task;
|
||||||
mod tokens;
|
mod tokens;
|
||||||
|
|
||||||
use cuprate_types::{Chain, ChainInfo, FeeEstimate, HardForkInfo};
|
use cuprate_types::{
|
||||||
|
rpc::{ChainInfo, FeeEstimate, HardForkInfo},
|
||||||
|
Chain,
|
||||||
|
};
|
||||||
use difficulty::DifficultyCache;
|
use difficulty::DifficultyCache;
|
||||||
use rx_vms::RandomXVm;
|
use rx_vms::RandomXVm;
|
||||||
use weight::BlockWeightsCache;
|
use weight::BlockWeightsCache;
|
||||||
|
|
|
@ -9,17 +9,21 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/rpc/types"
|
||||||
keywords = ["cuprate", "rpc", "types", "monero"]
|
keywords = ["cuprate", "rpc", "types", "monero"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["serde", "epee"]
|
default = ["serde", "epee", "from"]
|
||||||
serde = ["dep:serde", "cuprate-fixed-bytes/serde", "cuprate-types/serde"]
|
serde = ["dep:serde", "cuprate-fixed-bytes/serde", "cuprate-types/serde"]
|
||||||
epee = ["dep:cuprate-epee-encoding", "cuprate-types/epee"]
|
epee = ["dep:cuprate-epee-encoding", "cuprate-types/epee"]
|
||||||
|
from = ["dep:cuprate-helper", "cuprate-helper/map", "dep:cuprate-p2p-core", "dep:hex"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cuprate-epee-encoding = { workspace = true, optional = true }
|
cuprate-epee-encoding = { workspace = true, optional = true }
|
||||||
cuprate-fixed-bytes = { workspace = true }
|
cuprate-fixed-bytes = { workspace = true }
|
||||||
cuprate-types = { workspace = true, default-features = false }
|
cuprate-types = { workspace = true, default-features = false }
|
||||||
|
cuprate-helper = { workspace = true, optional = true, default-features = false }
|
||||||
|
cuprate-p2p-core = { workspace = true, optional = true, default-features = false }
|
||||||
|
|
||||||
paste = { workspace = true }
|
paste = { workspace = true }
|
||||||
serde = { workspace = true, optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
|
hex = { workspace = true, optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
cuprate-test-utils = { workspace = true }
|
cuprate-test-utils = { workspace = true }
|
||||||
|
|
|
@ -29,7 +29,7 @@ use crate::{macros::monero_definition_link, misc::Status};
|
||||||
//---------------------------------------------------------------------------------------------------- Requests
|
//---------------------------------------------------------------------------------------------------- Requests
|
||||||
/// A base for RPC request types that support RPC payment.
|
/// A base for RPC request types that support RPC payment.
|
||||||
///
|
///
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "rpc/core_rpc_server_commands_defs.h", 114..=122)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "rpc/core_rpc_server_commands_defs.h", 114..=122)]
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct AccessRequestBase {
|
pub struct AccessRequestBase {
|
||||||
|
@ -44,7 +44,7 @@ epee_object! {
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Responses
|
//---------------------------------------------------------------------------------------------------- Responses
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "rpc/core_rpc_server_commands_defs.h", 101..=112)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "rpc/core_rpc_server_commands_defs.h", 101..=112)]
|
||||||
/// The most common base for responses.
|
/// The most common base for responses.
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
@ -98,7 +98,7 @@ epee_object! {
|
||||||
untrusted: bool,
|
untrusted: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "rpc/core_rpc_server_commands_defs.h", 124..=136)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "rpc/core_rpc_server_commands_defs.h", 124..=136)]
|
||||||
/// A base for RPC response types that support RPC payment.
|
/// A base for RPC response types that support RPC payment.
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
|
|
@ -11,12 +11,15 @@ use serde::{Deserialize, Serialize};
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
use cuprate_epee_encoding::container_as_blob::ContainerAsBlob;
|
use cuprate_epee_encoding::container_as_blob::ContainerAsBlob;
|
||||||
|
|
||||||
use cuprate_types::BlockCompleteEntry;
|
use cuprate_types::{
|
||||||
|
rpc::{BlockOutputIndices, PoolInfo},
|
||||||
|
BlockCompleteEntry,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
base::AccessResponseBase,
|
base::AccessResponseBase,
|
||||||
macros::define_request_and_response,
|
macros::define_request_and_response,
|
||||||
misc::{BlockOutputIndices, GetOutputsOut, OutKeyBin, PoolInfo},
|
misc::{GetOutputsOut, OutKeyBin},
|
||||||
rpc_call::RpcCallValue,
|
rpc_call::RpcCallValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,28 +24,28 @@ use crate::macros::monero_definition_link;
|
||||||
// Note that these are _distinct_ from the ones in ZMQ:
|
// Note that these are _distinct_ from the ones in ZMQ:
|
||||||
// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/message.cpp#L40-L44>.
|
// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/message.cpp#L40-L44>.
|
||||||
|
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "/rpc/core_rpc_server_commands_defs.h", 78)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "/rpc/core_rpc_server_commands_defs.h", 78)]
|
||||||
pub const CORE_RPC_STATUS_OK: &str = "OK";
|
pub const CORE_RPC_STATUS_OK: &str = "OK";
|
||||||
|
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "/rpc/core_rpc_server_commands_defs.h", 79)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "/rpc/core_rpc_server_commands_defs.h", 79)]
|
||||||
pub const CORE_RPC_STATUS_BUSY: &str = "BUSY";
|
pub const CORE_RPC_STATUS_BUSY: &str = "BUSY";
|
||||||
|
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "/rpc/core_rpc_server_commands_defs.h", 80)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "/rpc/core_rpc_server_commands_defs.h", 80)]
|
||||||
pub const CORE_RPC_STATUS_NOT_MINING: &str = "NOT MINING";
|
pub const CORE_RPC_STATUS_NOT_MINING: &str = "NOT MINING";
|
||||||
|
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "/rpc/core_rpc_server_commands_defs.h", 81)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "/rpc/core_rpc_server_commands_defs.h", 81)]
|
||||||
pub const CORE_RPC_STATUS_PAYMENT_REQUIRED: &str = "PAYMENT REQUIRED";
|
pub const CORE_RPC_STATUS_PAYMENT_REQUIRED: &str = "PAYMENT REQUIRED";
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Versions
|
//---------------------------------------------------------------------------------------------------- Versions
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "/rpc/core_rpc_server_commands_defs.h", 90)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "/rpc/core_rpc_server_commands_defs.h", 90)]
|
||||||
/// RPC major version.
|
/// RPC major version.
|
||||||
pub const CORE_RPC_VERSION_MAJOR: u32 = 3;
|
pub const CORE_RPC_VERSION_MAJOR: u32 = 3;
|
||||||
|
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "/rpc/core_rpc_server_commands_defs.h", 91)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "/rpc/core_rpc_server_commands_defs.h", 91)]
|
||||||
/// RPC miror version.
|
/// RPC miror version.
|
||||||
pub const CORE_RPC_VERSION_MINOR: u32 = 14;
|
pub const CORE_RPC_VERSION_MINOR: u32 = 14;
|
||||||
|
|
||||||
#[doc = monero_definition_link!(cc73fe71162d564ffda8e549b79a350bca53c454, "/rpc/core_rpc_server_commands_defs.h", 92..=93)]
|
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "/rpc/core_rpc_server_commands_defs.h", 92..=93)]
|
||||||
/// RPC version.
|
/// RPC version.
|
||||||
pub const CORE_RPC_VERSION: u32 = (CORE_RPC_VERSION_MAJOR << 16) | CORE_RPC_VERSION_MINOR;
|
pub const CORE_RPC_VERSION: u32 = (CORE_RPC_VERSION_MAJOR << 16) | CORE_RPC_VERSION_MINOR;
|
||||||
|
|
||||||
|
|
230
rpc/types/src/from.rs
Normal file
230
rpc/types/src/from.rs
Normal file
|
@ -0,0 +1,230 @@
|
||||||
|
//! [`From`] implementations from other crate's types into [`crate`] types.
|
||||||
|
//!
|
||||||
|
//! Only non-crate types are imported, all crate types use `crate::`.
|
||||||
|
|
||||||
|
#![allow(unused_variables, unreachable_code, reason = "TODO")]
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
|
use cuprate_helper::map::combine_low_high_bits_to_u128;
|
||||||
|
use cuprate_p2p_core::{
|
||||||
|
types::{BanState, ConnectionId, ConnectionInfo, SetBan, Span},
|
||||||
|
ClearNet, NetZoneAddress, NetworkZone,
|
||||||
|
};
|
||||||
|
use cuprate_types::{
|
||||||
|
hex::Hex,
|
||||||
|
rpc::{
|
||||||
|
AuxPow, BlockHeader, BlockOutputIndices, ChainInfo, GetBan, GetMinerDataTxBacklogEntry,
|
||||||
|
GetOutputsOut, HardforkEntry, HistogramEntry, OutKey, OutKeyBin, OutputDistributionData,
|
||||||
|
Peer, PublicNode, SpentKeyImageInfo, TxBacklogEntry, TxInfo, TxOutputIndices, TxpoolHisto,
|
||||||
|
TxpoolStats,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <https://architecture.cuprate.org/oddities/le-ipv4.html>
|
||||||
|
const fn ipv4_from_u32(ip: u32) -> Ipv4Addr {
|
||||||
|
let [a, b, c, d] = ip.to_le_bytes();
|
||||||
|
Ipv4Addr::new(a, b, c, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Format two [`u64`]'s as a [`u128`] as a hexadecimal string prefixed with `0x`.
|
||||||
|
fn hex_prefix_u128(low: u64, high: u64) -> String {
|
||||||
|
format!("{:#x}", combine_low_high_bits_to_u128(low, high))
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<BlockHeader> for crate::misc::BlockHeader {
|
||||||
|
fn from(x: BlockHeader) -> Self {
|
||||||
|
Self {
|
||||||
|
block_size: x.block_weight,
|
||||||
|
block_weight: x.block_weight,
|
||||||
|
cumulative_difficulty_top64: x.cumulative_difficulty_top64,
|
||||||
|
cumulative_difficulty: x.cumulative_difficulty,
|
||||||
|
depth: x.depth,
|
||||||
|
difficulty_top64: x.difficulty_top64,
|
||||||
|
difficulty: x.difficulty,
|
||||||
|
hash: Hex(x.hash),
|
||||||
|
height: x.height,
|
||||||
|
long_term_weight: x.long_term_weight,
|
||||||
|
major_version: x.major_version,
|
||||||
|
miner_tx_hash: Hex(x.miner_tx_hash),
|
||||||
|
minor_version: x.minor_version,
|
||||||
|
nonce: x.nonce,
|
||||||
|
num_txes: x.num_txes,
|
||||||
|
orphan_status: x.orphan_status,
|
||||||
|
pow_hash: Hex(x.pow_hash),
|
||||||
|
prev_hash: Hex(x.prev_hash),
|
||||||
|
reward: x.reward,
|
||||||
|
timestamp: x.timestamp,
|
||||||
|
// FIXME: if we made a type that automatically did `hex_prefix_u128`,
|
||||||
|
// we wouldn't need `crate::misc::BlockHeader`.
|
||||||
|
wide_cumulative_difficulty: hex_prefix_u128(
|
||||||
|
x.cumulative_difficulty,
|
||||||
|
x.cumulative_difficulty_top64,
|
||||||
|
),
|
||||||
|
wide_difficulty: hex_prefix_u128(x.difficulty, x.difficulty_top64),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<A: NetZoneAddress> From<ConnectionInfo<A>> for crate::misc::ConnectionInfo {
|
||||||
|
fn from(x: ConnectionInfo<A>) -> Self {
|
||||||
|
let (ip, port) = match x.socket_addr {
|
||||||
|
Some(socket) => (socket.ip().to_string(), socket.port().to_string()),
|
||||||
|
None => (String::new(), String::new()),
|
||||||
|
};
|
||||||
|
|
||||||
|
Self {
|
||||||
|
address: x.address.to_string(),
|
||||||
|
address_type: x.address_type,
|
||||||
|
avg_download: x.avg_download,
|
||||||
|
avg_upload: x.avg_upload,
|
||||||
|
connection_id: String::from(ConnectionId::DEFAULT_STR),
|
||||||
|
current_download: x.current_download,
|
||||||
|
current_upload: x.current_upload,
|
||||||
|
height: x.height,
|
||||||
|
host: x.host,
|
||||||
|
incoming: x.incoming,
|
||||||
|
ip,
|
||||||
|
live_time: x.live_time,
|
||||||
|
localhost: x.localhost,
|
||||||
|
local_ip: x.local_ip,
|
||||||
|
peer_id: hex::encode(x.peer_id.to_ne_bytes()),
|
||||||
|
port,
|
||||||
|
pruning_seed: x.pruning_seed.compress(),
|
||||||
|
recv_count: x.recv_count,
|
||||||
|
recv_idle_time: x.recv_idle_time,
|
||||||
|
rpc_credits_per_hash: x.rpc_credits_per_hash,
|
||||||
|
rpc_port: x.rpc_port,
|
||||||
|
send_count: x.send_count,
|
||||||
|
send_idle_time: x.send_idle_time,
|
||||||
|
state: x.state,
|
||||||
|
support_flags: x.support_flags,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: support non-clearnet addresses.
|
||||||
|
impl From<crate::misc::SetBan> for SetBan<SocketAddr> {
|
||||||
|
fn from(x: crate::misc::SetBan) -> Self {
|
||||||
|
let address = SocketAddr::V4(SocketAddrV4::new(ipv4_from_u32(x.ip), 0));
|
||||||
|
|
||||||
|
let ban = if x.ban {
|
||||||
|
Some(Duration::from_secs(x.seconds.into()))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
Self { address, ban }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: do we need this type?
|
||||||
|
impl From<HistogramEntry> for crate::misc::HistogramEntry {
|
||||||
|
fn from(x: HistogramEntry) -> Self {
|
||||||
|
Self {
|
||||||
|
amount: x.amount,
|
||||||
|
total_instances: x.total_instances,
|
||||||
|
unlocked_instances: x.unlocked_instances,
|
||||||
|
recent_instances: x.recent_instances,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// impl From<HardforkEntry> for crate::misc::HardforkEntry {
|
||||||
|
// fn from(x: HardforkEntry) -> Self {
|
||||||
|
// Self {
|
||||||
|
// height: x.height,
|
||||||
|
// hf_version: x.hf_version,
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
impl From<ChainInfo> for crate::misc::ChainInfo {
|
||||||
|
fn from(x: ChainInfo) -> Self {
|
||||||
|
Self {
|
||||||
|
block_hash: Hex(x.block_hash),
|
||||||
|
block_hashes: x.block_hashes.into_iter().map(hex::encode).collect(),
|
||||||
|
difficulty_top64: x.difficulty_top64,
|
||||||
|
difficulty: x.difficulty,
|
||||||
|
height: x.height,
|
||||||
|
length: x.length,
|
||||||
|
main_chain_parent_block: Hex(x.main_chain_parent_block),
|
||||||
|
wide_difficulty: hex_prefix_u128(x.difficulty, x.difficulty_top64),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: support non-clearnet addresses.
|
||||||
|
impl From<Span<SocketAddr>> for crate::misc::Span {
|
||||||
|
fn from(x: Span<SocketAddr>) -> Self {
|
||||||
|
Self {
|
||||||
|
connection_id: String::from(ConnectionId::DEFAULT_STR),
|
||||||
|
nblocks: x.nblocks,
|
||||||
|
rate: x.rate,
|
||||||
|
remote_address: x.remote_address.to_string(),
|
||||||
|
size: x.size,
|
||||||
|
speed: x.speed,
|
||||||
|
start_block_height: x.start_block_height,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// impl From<OutputDistributionData> for crate::misc::OutputDistributionData {
|
||||||
|
// fn from(x: OutputDistributionData) -> Self {
|
||||||
|
// todo!();
|
||||||
|
|
||||||
|
// // Self {
|
||||||
|
// // distribution: Vec<u64>,
|
||||||
|
// // start_height: u64,
|
||||||
|
// // base: u64,
|
||||||
|
// // }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
impl From<TxInfo> for crate::misc::TxInfo {
|
||||||
|
fn from(x: TxInfo) -> Self {
|
||||||
|
Self {
|
||||||
|
blob_size: x.blob_size,
|
||||||
|
do_not_relay: x.do_not_relay,
|
||||||
|
double_spend_seen: x.double_spend_seen,
|
||||||
|
fee: x.fee,
|
||||||
|
id_hash: Hex(x.id_hash),
|
||||||
|
kept_by_block: x.kept_by_block,
|
||||||
|
last_failed_height: x.last_failed_height,
|
||||||
|
last_failed_id_hash: Hex(x.last_failed_id_hash),
|
||||||
|
last_relayed_time: x.last_relayed_time,
|
||||||
|
max_used_block_height: x.max_used_block_height,
|
||||||
|
max_used_block_id_hash: Hex(x.max_used_block_id_hash),
|
||||||
|
receive_time: x.receive_time,
|
||||||
|
relayed: x.relayed,
|
||||||
|
tx_blob: hex::encode(x.tx_blob),
|
||||||
|
tx_json: x.tx_json,
|
||||||
|
weight: x.weight,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<AuxPow> for crate::misc::AuxPow {
|
||||||
|
fn from(x: AuxPow) -> Self {
|
||||||
|
Self {
|
||||||
|
id: Hex(x.id),
|
||||||
|
hash: Hex(x.hash),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hex() {
|
||||||
|
assert_eq!(hex_prefix_u128(0, 0), "0x0");
|
||||||
|
assert_eq!(hex_prefix_u128(0, u64::MAX), "0x0");
|
||||||
|
assert_eq!(hex_prefix_u128(u64::MAX, 0), "0x0");
|
||||||
|
assert_eq!(hex_prefix_u128(u64::MAX, u64::MAX), "0x0");
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,13 +6,14 @@
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use cuprate_types::rpc::{GetMinerDataTxBacklogEntry, HardforkEntry, TxBacklogEntry};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
base::{AccessResponseBase, ResponseBase},
|
base::{AccessResponseBase, ResponseBase},
|
||||||
macros::define_request_and_response,
|
macros::define_request_and_response,
|
||||||
misc::{
|
misc::{
|
||||||
AuxPow, BlockHeader, ChainInfo, ConnectionInfo, Distribution, GetBan,
|
AuxPow, BlockHeader, ChainInfo, ConnectionInfo, Distribution, GetBan, HistogramEntry,
|
||||||
GetMinerDataTxBacklogEntry, HardforkEntry, HistogramEntry, SetBan, Span, Status,
|
SetBan, Span, Status, SyncInfoPeer,
|
||||||
SyncInfoPeer, TxBacklogEntry,
|
|
||||||
},
|
},
|
||||||
rpc_call::RpcCallValue,
|
rpc_call::RpcCallValue,
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,8 @@ mod constants;
|
||||||
#[cfg(any(feature = "serde", feature = "epee"))]
|
#[cfg(any(feature = "serde", feature = "epee"))]
|
||||||
mod defaults;
|
mod defaults;
|
||||||
mod free;
|
mod free;
|
||||||
|
#[cfg(feature = "from")]
|
||||||
|
mod from;
|
||||||
mod macros;
|
mod macros;
|
||||||
mod rpc_call;
|
mod rpc_call;
|
||||||
|
|
||||||
|
|
|
@ -408,13 +408,13 @@ pub(crate) use define_request_and_response_doc;
|
||||||
/// Output a string link to `monerod` source code.
|
/// Output a string link to `monerod` source code.
|
||||||
macro_rules! monero_definition_link {
|
macro_rules! monero_definition_link {
|
||||||
(
|
(
|
||||||
$commit:ident, // Git commit hash
|
$commit:literal, // Git commit hash
|
||||||
$file_path:literal, // File path within `monerod`'s `src/`, e.g. `rpc/core_rpc_server_commands_defs.h`
|
$file_path:literal, // File path within `monerod`'s `src/`, e.g. `rpc/core_rpc_server_commands_defs.h`
|
||||||
$start:literal$(..=$end:literal)? // File lines, e.g. `0..=123` or `0`
|
$start:literal$(..=$end:literal)? // File lines, e.g. `0..=123` or `0`
|
||||||
) => {
|
) => {
|
||||||
concat!(
|
concat!(
|
||||||
"[Definition](https://github.com/monero-project/monero/blob/",
|
"[Definition](https://github.com/monero-project/monero/blob/",
|
||||||
stringify!($commit),
|
$commit,
|
||||||
"/src/",
|
"/src/",
|
||||||
$file_path,
|
$file_path,
|
||||||
"#L",
|
"#L",
|
||||||
|
|
|
@ -16,7 +16,7 @@ use cuprate_epee_encoding::{
|
||||||
///
|
///
|
||||||
/// Used for [`Distribution::CompressedBinary::distribution`].
|
/// Used for [`Distribution::CompressedBinary::distribution`].
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
#[doc = crate::macros::monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
45..=55
|
45..=55
|
||||||
)]
|
)]
|
||||||
|
@ -29,7 +29,7 @@ fn compress_integer_array(_: &[u64]) -> Vec<u8> {
|
||||||
///
|
///
|
||||||
/// Used for [`Distribution::CompressedBinary::distribution`].
|
/// Used for [`Distribution::CompressedBinary::distribution`].
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
#[doc = crate::macros::monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
57..=72
|
57..=72
|
||||||
)]
|
)]
|
||||||
|
@ -40,7 +40,7 @@ fn decompress_integer_array(_: &[u8]) -> Vec<u64> {
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Distribution
|
//---------------------------------------------------------------------------------------------------- Distribution
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
#[doc = crate::macros::monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
2468..=2508
|
2468..=2508
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -13,7 +13,7 @@ use cuprate_epee_encoding::{
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- KeyImageSpentStatus
|
//---------------------------------------------------------------------------------------------------- KeyImageSpentStatus
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
#[doc = crate::macros::monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
456..=460
|
456..=460
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -15,25 +15,18 @@
|
||||||
mod binary_string;
|
mod binary_string;
|
||||||
mod distribution;
|
mod distribution;
|
||||||
mod key_image_spent_status;
|
mod key_image_spent_status;
|
||||||
#[expect(clippy::module_inception)]
|
|
||||||
mod misc;
|
|
||||||
mod pool_info;
|
|
||||||
mod pool_info_extent;
|
|
||||||
mod requested_info;
|
mod requested_info;
|
||||||
mod status;
|
mod status;
|
||||||
mod tx_entry;
|
mod tx_entry;
|
||||||
|
mod types;
|
||||||
|
|
||||||
pub use binary_string::BinaryString;
|
pub use binary_string::BinaryString;
|
||||||
pub use distribution::{Distribution, DistributionCompressedBinary, DistributionUncompressed};
|
pub use distribution::{Distribution, DistributionCompressedBinary, DistributionUncompressed};
|
||||||
pub use key_image_spent_status::KeyImageSpentStatus;
|
pub use key_image_spent_status::KeyImageSpentStatus;
|
||||||
pub use misc::{
|
|
||||||
AuxPow, BlockHeader, BlockOutputIndices, ChainInfo, ConnectionInfo, GetBan,
|
|
||||||
GetMinerDataTxBacklogEntry, GetOutputsOut, HardforkEntry, HistogramEntry, OutKey, OutKeyBin,
|
|
||||||
OutputDistributionData, Peer, PoolTxInfo, PublicNode, SetBan, Span, SpentKeyImageInfo,
|
|
||||||
SyncInfoPeer, TxBacklogEntry, TxInfo, TxOutputIndices, TxpoolHisto, TxpoolStats,
|
|
||||||
};
|
|
||||||
pub use pool_info::PoolInfo;
|
|
||||||
pub use pool_info_extent::PoolInfoExtent;
|
|
||||||
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;
|
||||||
|
pub use types::{
|
||||||
|
AuxPow, BlockHeader, ChainInfo, ConnectionInfo, GetBan, GetOutputsOut, HistogramEntry,
|
||||||
|
OutKeyBin, SetBan, Span, SpentKeyImageInfo, SyncInfoPeer, TxInfo,
|
||||||
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ use cuprate_epee_encoding::{
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- RequestedInfo
|
//---------------------------------------------------------------------------------------------------- RequestedInfo
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
#[doc = crate::macros::monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
178..=183
|
178..=183
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate::serde::{serde_false, serde_true};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TxEntry
|
//---------------------------------------------------------------------------------------------------- TxEntry
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
#[doc = crate::macros::monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
389..=428
|
389..=428
|
||||||
)]
|
)]
|
||||||
|
|
326
rpc/types/src/misc/types.rs
Normal file
326
rpc/types/src/misc/types.rs
Normal file
|
@ -0,0 +1,326 @@
|
||||||
|
//! Miscellaneous types.
|
||||||
|
//!
|
||||||
|
//! These are `struct`s that appear in request/response types.
|
||||||
|
//! For example, [`crate::json::GetConnectionsResponse`] contains
|
||||||
|
//! the [`crate::misc::ConnectionInfo`] struct defined here.
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
|
use cuprate_types::{hex::Hex, HardFork};
|
||||||
|
|
||||||
|
#[cfg(any(feature = "epee", feature = "serde"))]
|
||||||
|
use crate::defaults::default_zero;
|
||||||
|
|
||||||
|
use crate::macros::monero_definition_link;
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- Macros
|
||||||
|
/// This macro (local to this file) defines all the misc types.
|
||||||
|
///
|
||||||
|
/// This macro:
|
||||||
|
/// 1. Defines a `pub struct` with all `pub` fields
|
||||||
|
/// 2. Implements `serde` on the struct
|
||||||
|
/// 3. Implements `epee` on the struct
|
||||||
|
///
|
||||||
|
/// When using, consider documenting:
|
||||||
|
/// - The original Monero definition site with [`monero_definition_link`]
|
||||||
|
/// - The request/responses where the `struct` is used
|
||||||
|
macro_rules! define_struct_and_impl_epee {
|
||||||
|
($(
|
||||||
|
// Optional `struct` attributes.
|
||||||
|
$( #[$struct_attr:meta] )*
|
||||||
|
// The `struct`'s name.
|
||||||
|
$struct_name:ident {
|
||||||
|
// And any fields.
|
||||||
|
$(
|
||||||
|
$( #[$field_attr:meta] )* // Field attributes
|
||||||
|
// Field name => the type => optional `epee_object` default value.
|
||||||
|
$field_name:ident: $field_type:ty $(= $field_default:expr_2021)?,
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
)*) => {
|
||||||
|
$(
|
||||||
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
|
$( #[$struct_attr] )*
|
||||||
|
pub struct $struct_name {
|
||||||
|
$(
|
||||||
|
$( #[$field_attr] )*
|
||||||
|
pub $field_name: $field_type,
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "epee")]
|
||||||
|
cuprate_epee_encoding::epee_object! {
|
||||||
|
$struct_name,
|
||||||
|
$(
|
||||||
|
$field_name: $field_type $(= $field_default)?,
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- Type Definitions
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1163..=1212
|
||||||
|
)]
|
||||||
|
///
|
||||||
|
/// Used in:
|
||||||
|
/// - [`crate::json::GetLastBlockHeaderResponse`]
|
||||||
|
/// - [`crate::json::GetBlockHeaderByHashResponse`]
|
||||||
|
/// - [`crate::json::GetBlockHeaderByHeightResponse`]
|
||||||
|
/// - [`crate::json::GetBlockHeadersRangeResponse`]
|
||||||
|
/// - [`crate::json::GetBlockResponse`]
|
||||||
|
BlockHeader {
|
||||||
|
block_size: u64,
|
||||||
|
block_weight: u64,
|
||||||
|
cumulative_difficulty_top64: u64,
|
||||||
|
cumulative_difficulty: u64,
|
||||||
|
depth: u64,
|
||||||
|
difficulty_top64: u64,
|
||||||
|
difficulty: u64,
|
||||||
|
hash: Hex<32>,
|
||||||
|
height: u64,
|
||||||
|
long_term_weight: u64,
|
||||||
|
major_version: HardFork,
|
||||||
|
miner_tx_hash: Hex<32>,
|
||||||
|
minor_version: u8,
|
||||||
|
nonce: u32,
|
||||||
|
num_txes: u64,
|
||||||
|
orphan_status: bool,
|
||||||
|
pow_hash: Hex<32>,
|
||||||
|
prev_hash: Hex<32>,
|
||||||
|
reward: u64,
|
||||||
|
timestamp: u64,
|
||||||
|
wide_cumulative_difficulty: String,
|
||||||
|
wide_difficulty: String,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"cryptonote_protocol/cryptonote_protocol_defs.h",
|
||||||
|
47..=116
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::json::GetConnectionsResponse`].
|
||||||
|
ConnectionInfo {
|
||||||
|
address: String,
|
||||||
|
address_type: cuprate_types::AddressType,
|
||||||
|
avg_download: u64,
|
||||||
|
avg_upload: u64,
|
||||||
|
connection_id: String,
|
||||||
|
current_download: u64,
|
||||||
|
current_upload: u64,
|
||||||
|
height: u64,
|
||||||
|
host: String,
|
||||||
|
incoming: bool,
|
||||||
|
ip: String,
|
||||||
|
live_time: u64,
|
||||||
|
localhost: bool,
|
||||||
|
local_ip: bool,
|
||||||
|
peer_id: String,
|
||||||
|
port: String,
|
||||||
|
pruning_seed: u32,
|
||||||
|
recv_count: u64,
|
||||||
|
recv_idle_time: u64,
|
||||||
|
rpc_credits_per_hash: u32,
|
||||||
|
rpc_port: u16,
|
||||||
|
send_count: u64,
|
||||||
|
send_idle_time: u64,
|
||||||
|
// Exists in the original definition, but isn't
|
||||||
|
// used or (de)serialized for RPC purposes.
|
||||||
|
// ssl: bool,
|
||||||
|
state: cuprate_types::ConnectionState,
|
||||||
|
support_flags: u32,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2034..=2047
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::json::SetBansRequest`].
|
||||||
|
SetBan {
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "crate::defaults::default_string"))]
|
||||||
|
host: String,
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
ip: u32,
|
||||||
|
ban: bool,
|
||||||
|
seconds: u32,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1999..=2010
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::json::GetBansResponse`].
|
||||||
|
GetBan {
|
||||||
|
host: String,
|
||||||
|
ip: u32,
|
||||||
|
seconds: u32,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2139..=2156
|
||||||
|
)]
|
||||||
|
#[derive(Copy)]
|
||||||
|
/// Used in [`crate::json::GetOutputHistogramResponse`].
|
||||||
|
HistogramEntry {
|
||||||
|
amount: u64,
|
||||||
|
total_instances: u64,
|
||||||
|
unlocked_instances: u64,
|
||||||
|
recent_instances: u64,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2289..=2310
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::json::GetAlternateChainsResponse`].
|
||||||
|
ChainInfo {
|
||||||
|
block_hash: Hex<32>,
|
||||||
|
block_hashes: Vec<String>, // TODO: Vec<Hex<32>> when it has epee
|
||||||
|
difficulty: u64,
|
||||||
|
difficulty_top64: u64,
|
||||||
|
height: u64,
|
||||||
|
length: u64,
|
||||||
|
main_chain_parent_block: Hex<32>,
|
||||||
|
wide_difficulty: String,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2393..=2400
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::json::SyncInfoResponse`].
|
||||||
|
SyncInfoPeer {
|
||||||
|
info: ConnectionInfo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2402..=2421
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::json::SyncInfoResponse`].
|
||||||
|
Span {
|
||||||
|
connection_id: String,
|
||||||
|
nblocks: u64,
|
||||||
|
rate: u32,
|
||||||
|
remote_address: String,
|
||||||
|
size: u64,
|
||||||
|
speed: u32,
|
||||||
|
start_block_height: u64,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
512..=521
|
||||||
|
)]
|
||||||
|
#[derive(Copy)]
|
||||||
|
///
|
||||||
|
/// Used in:
|
||||||
|
/// - [`crate::bin::GetOutsRequest`]
|
||||||
|
/// - [`crate::other::GetOutsRequest`]
|
||||||
|
GetOutputsOut {
|
||||||
|
amount: u64,
|
||||||
|
index: u64,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
538..=553
|
||||||
|
)]
|
||||||
|
#[derive(Copy)]
|
||||||
|
/// Used in [`crate::bin::GetOutsRequest`].
|
||||||
|
OutKeyBin {
|
||||||
|
key: [u8; 32],
|
||||||
|
mask: [u8; 32],
|
||||||
|
unlocked: bool,
|
||||||
|
height: u64,
|
||||||
|
txid: [u8; 32],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1519..=1556
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::other::GetTransactionPoolResponse`].
|
||||||
|
TxInfo {
|
||||||
|
blob_size: u64,
|
||||||
|
do_not_relay: bool,
|
||||||
|
double_spend_seen: bool,
|
||||||
|
fee: u64,
|
||||||
|
id_hash: Hex<32>,
|
||||||
|
kept_by_block: bool,
|
||||||
|
last_failed_height: u64,
|
||||||
|
last_failed_id_hash: Hex<32>,
|
||||||
|
last_relayed_time: u64,
|
||||||
|
max_used_block_height: u64,
|
||||||
|
max_used_block_id_hash: Hex<32>,
|
||||||
|
receive_time: u64,
|
||||||
|
relayed: bool,
|
||||||
|
tx_blob: String,
|
||||||
|
tx_json: cuprate_types::json::tx::Transaction,
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
weight: u64 = default_zero::<u64>(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1558..=1567
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::other::GetTransactionPoolResponse`].
|
||||||
|
SpentKeyImageInfo {
|
||||||
|
id_hash: Hex<32>,
|
||||||
|
txs_hashes: Vec<String>, // TODO: Vec<Hex<32>> when it has epee
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1070..=1079
|
||||||
|
)]
|
||||||
|
AuxPow {
|
||||||
|
id: Hex<32>,
|
||||||
|
hash: Hex<32>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {}
|
|
@ -6,13 +6,12 @@
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use cuprate_types::rpc::{OutKey, Peer, PublicNode, TxpoolStats};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
base::{AccessResponseBase, ResponseBase},
|
base::{AccessResponseBase, ResponseBase},
|
||||||
macros::define_request_and_response,
|
macros::define_request_and_response,
|
||||||
misc::{
|
misc::{GetOutputsOut, SpentKeyImageInfo, Status, TxEntry, TxInfo},
|
||||||
GetOutputsOut, OutKey, Peer, PublicNode, SpentKeyImageInfo, Status, TxEntry, TxInfo,
|
|
||||||
TxpoolStats,
|
|
||||||
},
|
|
||||||
RpcCallValue,
|
RpcCallValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThre
|
||||||
use cuprate_helper::map::combine_low_high_bits_to_u128;
|
use cuprate_helper::map::combine_low_high_bits_to_u128;
|
||||||
use cuprate_types::{
|
use cuprate_types::{
|
||||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||||
Chain, ChainId, ExtendedBlockHeader, OutputHistogramInput, OutputOnChain, TxsInBlock,
|
rpc::OutputHistogramInput,
|
||||||
|
Chain, ChainId, ExtendedBlockHeader, OutputOnChain, TxsInBlock,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -20,7 +20,7 @@ serde = ["dep:serde", "cuprate-database/serde", "cuprate-database-service/
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cuprate-database = { workspace = true, features = ["heed"] }
|
cuprate-database = { workspace = true, features = ["heed"] }
|
||||||
cuprate-database-service = { workspace = true }
|
cuprate-database-service = { workspace = true }
|
||||||
cuprate-types = { workspace = true }
|
cuprate-types = { workspace = true, features = ["rpc"] }
|
||||||
cuprate-helper = { workspace = true, default-features = false, features = ["constants"] }
|
cuprate-helper = { workspace = true, default-features = false, features = ["constants"] }
|
||||||
|
|
||||||
monero-serai = { workspace = true, features = ["std"] }
|
monero-serai = { workspace = true, features = ["std"] }
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
//! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums.
|
//! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums.
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
|
num::NonZero,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use cuprate_types::TransactionVerificationData;
|
use cuprate_types::{rpc::PoolInfo, TransactionVerificationData};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
tx::TxEntry,
|
tx::TxEntry,
|
||||||
|
@ -40,6 +41,17 @@ pub enum TxpoolReadRequest {
|
||||||
/// include private transactions in the pool.
|
/// include private transactions in the pool.
|
||||||
include_sensitive_txs: bool,
|
include_sensitive_txs: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Get general information on the txpool.
|
||||||
|
PoolInfo {
|
||||||
|
/// If this is [`true`], the size returned will
|
||||||
|
/// include private transactions in the pool.
|
||||||
|
include_sensitive_txs: bool,
|
||||||
|
/// TODO
|
||||||
|
max_tx_count: usize,
|
||||||
|
/// TODO
|
||||||
|
start_time: Option<NonZero<usize>>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse
|
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse
|
||||||
|
@ -79,6 +91,9 @@ pub enum TxpoolReadResponse {
|
||||||
/// The inner value is the amount of
|
/// The inner value is the amount of
|
||||||
/// transactions currently in the pool.
|
/// transactions currently in the pool.
|
||||||
Size(usize),
|
Size(usize),
|
||||||
|
|
||||||
|
/// Response to [`TxpoolReadRequest::PoolInfo`].
|
||||||
|
PoolInfo(Vec<PoolInfo>),
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest
|
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
)]
|
)]
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
|
num::NonZero,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,6 +75,11 @@ fn map_request(
|
||||||
TxpoolReadRequest::Size {
|
TxpoolReadRequest::Size {
|
||||||
include_sensitive_txs,
|
include_sensitive_txs,
|
||||||
} => size(env, include_sensitive_txs),
|
} => size(env, include_sensitive_txs),
|
||||||
|
TxpoolReadRequest::PoolInfo {
|
||||||
|
include_sensitive_txs,
|
||||||
|
max_tx_count,
|
||||||
|
start_time,
|
||||||
|
} => pool_info(include_sensitive_txs, max_tx_count, start_time),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,3 +212,12 @@ fn backlog(env: &ConcreteEnv) -> ReadResponseResult {
|
||||||
fn size(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
|
fn size(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
|
||||||
Ok(TxpoolReadResponse::Size(todo!()))
|
Ok(TxpoolReadResponse::Size(todo!()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`TxpoolReadRequest::PoolInfo`].
|
||||||
|
fn pool_info(
|
||||||
|
include_sensitive_txs: bool,
|
||||||
|
max_tx_count: usize,
|
||||||
|
start_time: Option<NonZero<usize>>,
|
||||||
|
) -> ReadResponseResult {
|
||||||
|
Ok(TxpoolReadResponse::PoolInfo(todo!()))
|
||||||
|
}
|
||||||
|
|
|
@ -9,22 +9,24 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/types"
|
||||||
keywords = ["cuprate", "types"]
|
keywords = ["cuprate", "types"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["blockchain", "epee", "serde", "json", "hex"]
|
default = ["blockchain", "epee", "serde", "json", "hex", "rpc"]
|
||||||
blockchain = []
|
blockchain = ["rpc"]
|
||||||
epee = ["dep:cuprate-epee-encoding"]
|
epee = ["dep:cuprate-epee-encoding"]
|
||||||
serde = ["dep:serde", "hex"]
|
serde = ["dep:serde", "hex"]
|
||||||
proptest = ["dep:proptest", "dep:proptest-derive"]
|
proptest = ["dep:proptest", "dep:proptest-derive"]
|
||||||
json = ["hex", "dep:cuprate-helper"]
|
json = ["hex", "dep:cuprate-helper"]
|
||||||
# We sadly have no choice but to enable serde here as otherwise we will get warnings from the `hex` dep being unused.
|
# We sadly have no choice but to enable serde here as otherwise we will get warnings from the `hex` dep being unused.
|
||||||
# This isn't too bad as `HexBytes` only makes sense with serde anyway.
|
# This isn't too bad as `Hex` only makes sense with serde anyway.
|
||||||
hex = ["serde", "dep:hex"]
|
hex = ["serde", "dep:hex"]
|
||||||
|
rpc = ["hex"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cuprate-epee-encoding = { workspace = true, optional = true, features = ["std"] }
|
cuprate-epee-encoding = { workspace = true, optional = true, features = ["std"] }
|
||||||
cuprate-helper = { workspace = true, optional = true, features = ["cast"] }
|
cuprate-helper = { workspace = true, optional = true, features = ["cast"] }
|
||||||
cuprate-fixed-bytes = { workspace = true, features = ["std", "serde"] }
|
cuprate-fixed-bytes = { workspace = true, features = ["std", "serde"] }
|
||||||
|
|
||||||
bytes = { workspace = true }
|
bytes = { workspace = true }
|
||||||
|
cfg-if = { workspace = true }
|
||||||
curve25519-dalek = { workspace = true }
|
curve25519-dalek = { workspace = true }
|
||||||
monero-serai = { workspace = true }
|
monero-serai = { workspace = true }
|
||||||
hex = { workspace = true, features = ["serde", "alloc"], optional = true }
|
hex = { workspace = true, features = ["serde", "alloc"], optional = true }
|
||||||
|
|
|
@ -12,10 +12,11 @@ use monero_serai::block::Block;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
types::{Chain, ExtendedBlockHeader, OutputOnChain, TxsInBlock, VerifiedBlockInformation},
|
types::{Chain, ExtendedBlockHeader, OutputOnChain, TxsInBlock, VerifiedBlockInformation},
|
||||||
AltBlockInformation, BlockCompleteEntry, ChainId, ChainInfo, CoinbaseTxSum,
|
AltBlockInformation, BlockCompleteEntry, ChainId,
|
||||||
OutputHistogramEntry, OutputHistogramInput,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::rpc::{ChainInfo, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- ReadRequest
|
//---------------------------------------------------------------------------------------------------- ReadRequest
|
||||||
/// A read request to the blockchain database.
|
/// A read request to the blockchain database.
|
||||||
///
|
///
|
||||||
|
|
|
@ -7,6 +7,13 @@ use strum::{
|
||||||
|
|
||||||
use monero_serai::block::BlockHeader;
|
use monero_serai::block::BlockHeader;
|
||||||
|
|
||||||
|
#[cfg(feature = "epee")]
|
||||||
|
use cuprate_epee_encoding::{
|
||||||
|
error,
|
||||||
|
macros::bytes::{Buf, BufMut},
|
||||||
|
EpeeValue, Marker,
|
||||||
|
};
|
||||||
|
|
||||||
/// Target block time for hf 1.
|
/// Target block time for hf 1.
|
||||||
///
|
///
|
||||||
/// ref: <https://monero-book.cuprate.org/consensus_rules/blocks/difficulty.html#target-seconds>
|
/// ref: <https://monero-book.cuprate.org/consensus_rules/blocks/difficulty.html#target-seconds>
|
||||||
|
@ -51,6 +58,7 @@ pub enum HardForkError {
|
||||||
VariantArray,
|
VariantArray,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(any(feature = "proptest"), derive(proptest_derive::Arbitrary))]
|
#[cfg_attr(any(feature = "proptest"), derive(proptest_derive::Arbitrary))]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum HardFork {
|
pub enum HardFork {
|
||||||
#[default]
|
#[default]
|
||||||
|
@ -194,3 +202,19 @@ impl HardFork {
|
||||||
matches!(self, Self::LATEST)
|
matches!(self, Self::LATEST)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "epee")]
|
||||||
|
impl EpeeValue for HardFork {
|
||||||
|
const MARKER: Marker = u8::MARKER;
|
||||||
|
|
||||||
|
fn read<B: Buf>(r: &mut B, marker: &Marker) -> error::Result<Self> {
|
||||||
|
let u = u8::read(r, marker)?;
|
||||||
|
Self::from_repr(u).ok_or(error::Error::Format("unknown hardfork"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write<B: BufMut>(self, w: &mut B) -> error::Result<()> {
|
||||||
|
let u = self.as_u8();
|
||||||
|
u8::write(u, w)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -18,12 +18,12 @@ use serde::{Deserialize, Serialize};
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(transparent))]
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct HexBytes<const N: usize>(
|
pub struct Hex<const N: usize>(
|
||||||
#[cfg_attr(feature = "serde", serde(with = "hex::serde"))] pub [u8; N],
|
#[cfg_attr(feature = "serde", serde(with = "hex::serde"))] pub [u8; N],
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
impl<'de, const N: usize> Deserialize<'de> for HexBytes<N>
|
impl<'de, const N: usize> Deserialize<'de> for Hex<N>
|
||||||
where
|
where
|
||||||
[u8; N]: hex::FromHex,
|
[u8; N]: hex::FromHex,
|
||||||
<[u8; N] as hex::FromHex>::Error: std::fmt::Display,
|
<[u8; N] as hex::FromHex>::Error: std::fmt::Display,
|
||||||
|
@ -37,7 +37,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
impl<const N: usize> EpeeValue for HexBytes<N> {
|
impl<const N: usize> EpeeValue for Hex<N> {
|
||||||
const MARKER: Marker = <[u8; N] as EpeeValue>::MARKER;
|
const MARKER: Marker = <[u8; N] as EpeeValue>::MARKER;
|
||||||
|
|
||||||
fn read<B: bytes::Buf>(r: &mut B, marker: &Marker) -> error::Result<Self> {
|
fn read<B: bytes::Buf>(r: &mut B, marker: &Marker) -> error::Result<Self> {
|
||||||
|
@ -50,7 +50,7 @@ impl<const N: usize> EpeeValue for HexBytes<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default is not implemented for arrays >32, so we must do it manually.
|
// Default is not implemented for arrays >32, so we must do it manually.
|
||||||
impl<const N: usize> Default for HexBytes<N> {
|
impl<const N: usize> Default for Hex<N> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self([0; N])
|
Self([0; N])
|
||||||
}
|
}
|
||||||
|
@ -63,13 +63,13 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn hex_bytes_32() {
|
fn hex_bytes_32() {
|
||||||
let hash = [1; 32];
|
let hash = [1; 32];
|
||||||
let hex_bytes = HexBytes::<32>(hash);
|
let hex_bytes = Hex::<32>(hash);
|
||||||
let expected_json = r#""0101010101010101010101010101010101010101010101010101010101010101""#;
|
let expected_json = r#""0101010101010101010101010101010101010101010101010101010101010101""#;
|
||||||
|
|
||||||
let to_string = serde_json::to_string(&hex_bytes).unwrap();
|
let to_string = serde_json::to_string(&hex_bytes).unwrap();
|
||||||
assert_eq!(to_string, expected_json);
|
assert_eq!(to_string, expected_json);
|
||||||
|
|
||||||
let from_str = serde_json::from_str::<HexBytes<32>>(expected_json).unwrap();
|
let from_str = serde_json::from_str::<Hex<32>>(expected_json).unwrap();
|
||||||
assert_eq!(hex_bytes, from_str);
|
assert_eq!(hex_bytes, from_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use monero_serai::{block, transaction};
|
||||||
use cuprate_helper::cast::usize_to_u64;
|
use cuprate_helper::cast::usize_to_u64;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
hex::HexBytes,
|
hex::Hex,
|
||||||
json::output::{Output, TaggedKey, Target},
|
json::output::{Output, TaggedKey, Target},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ pub struct Block {
|
||||||
pub major_version: u8,
|
pub major_version: u8,
|
||||||
pub minor_version: u8,
|
pub minor_version: u8,
|
||||||
pub timestamp: u64,
|
pub timestamp: u64,
|
||||||
pub prev_id: HexBytes<32>,
|
pub prev_id: Hex<32>,
|
||||||
pub nonce: u32,
|
pub nonce: u32,
|
||||||
pub miner_tx: MinerTransaction,
|
pub miner_tx: MinerTransaction,
|
||||||
pub tx_hashes: Vec<HexBytes<32>>,
|
pub tx_hashes: Vec<Hex<32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<block::Block> for Block {
|
impl From<block::Block> for Block {
|
||||||
|
@ -34,13 +34,13 @@ impl From<block::Block> for Block {
|
||||||
unreachable!("input is a miner tx, this should never fail");
|
unreachable!("input is a miner tx, this should never fail");
|
||||||
};
|
};
|
||||||
|
|
||||||
let tx_hashes = b.transactions.into_iter().map(HexBytes::<32>).collect();
|
let tx_hashes = b.transactions.into_iter().map(Hex::<32>).collect();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
major_version: b.header.hardfork_version,
|
major_version: b.header.hardfork_version,
|
||||||
minor_version: b.header.hardfork_signal,
|
minor_version: b.header.hardfork_signal,
|
||||||
timestamp: b.header.timestamp,
|
timestamp: b.header.timestamp,
|
||||||
prev_id: HexBytes::<32>(b.header.previous),
|
prev_id: Hex::<32>(b.header.previous),
|
||||||
nonce: b.header.nonce,
|
nonce: b.header.nonce,
|
||||||
miner_tx,
|
miner_tx,
|
||||||
tx_hashes,
|
tx_hashes,
|
||||||
|
@ -101,14 +101,14 @@ impl TryFrom<transaction::Transaction> for MinerTransaction {
|
||||||
let target = match o.view_tag {
|
let target = match o.view_tag {
|
||||||
Some(view_tag) => {
|
Some(view_tag) => {
|
||||||
let tagged_key = TaggedKey {
|
let tagged_key = TaggedKey {
|
||||||
key: HexBytes::<32>(o.key.0),
|
key: Hex::<32>(o.key.0),
|
||||||
view_tag: HexBytes::<1>([view_tag]),
|
view_tag: Hex::<1>([view_tag]),
|
||||||
};
|
};
|
||||||
|
|
||||||
Target::TaggedKey { tagged_key }
|
Target::TaggedKey { tagged_key }
|
||||||
}
|
}
|
||||||
None => Target::Key {
|
None => Target::Key {
|
||||||
key: HexBytes::<32>(o.key.0),
|
key: Hex::<32>(o.key.0),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ mod test {
|
||||||
major_version: 1,
|
major_version: 1,
|
||||||
minor_version: 0,
|
minor_version: 0,
|
||||||
timestamp: 1415690591,
|
timestamp: 1415690591,
|
||||||
prev_id: HexBytes::<32>(hex!(
|
prev_id: Hex::<32>(hex!(
|
||||||
"e97a0ab6307de9b9f9a9872263ef3e957976fb227eb9422c6854e989e5d5d34c"
|
"e97a0ab6307de9b9f9a9872263ef3e957976fb227eb9422c6854e989e5d5d34c"
|
||||||
)),
|
)),
|
||||||
nonce: 2147484616,
|
nonce: 2147484616,
|
||||||
|
@ -237,25 +237,25 @@ mod test {
|
||||||
Output {
|
Output {
|
||||||
amount: 47019296802,
|
amount: 47019296802,
|
||||||
target: Target::Key {
|
target: Target::Key {
|
||||||
key: HexBytes::<32>(hex!("3c1dcbf5b485987ecef4596bb700e32cbc7bd05964e3888ffc05f8a46bf5fc33")),
|
key: Hex::<32>(hex!("3c1dcbf5b485987ecef4596bb700e32cbc7bd05964e3888ffc05f8a46bf5fc33")),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Output {
|
Output {
|
||||||
amount: 200000000000,
|
amount: 200000000000,
|
||||||
target: Target::Key {
|
target: Target::Key {
|
||||||
key: HexBytes::<32>(hex!("5810afc7a1b01a1c913eb6aab15d4a851cbc4a8cf0adf90bb80ac1a7ca9928aa")),
|
key: Hex::<32>(hex!("5810afc7a1b01a1c913eb6aab15d4a851cbc4a8cf0adf90bb80ac1a7ca9928aa")),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Output {
|
Output {
|
||||||
amount: 3000000000000,
|
amount: 3000000000000,
|
||||||
target: Target::Key {
|
target: Target::Key {
|
||||||
key: HexBytes::<32>(hex!("520f49c5f2ce8456dc1a565f35ed3a5ccfff3a1210b340870a57d2749a81a2df")),
|
key: Hex::<32>(hex!("520f49c5f2ce8456dc1a565f35ed3a5ccfff3a1210b340870a57d2749a81a2df")),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Output {
|
Output {
|
||||||
amount: 10000000000000,
|
amount: 10000000000000,
|
||||||
target: Target::Key {
|
target: Target::Key {
|
||||||
key: HexBytes::<32>(hex!("44d7705e62c76c2e349a474df6724aa1d9932092002b03a94f9c19d9d12b9427")),
|
key: Hex::<32>(hex!("44d7705e62c76c2e349a474df6724aa1d9932092002b03a94f9c19d9d12b9427")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -281,7 +281,7 @@ mod test {
|
||||||
major_version: 16,
|
major_version: 16,
|
||||||
minor_version: 16,
|
minor_version: 16,
|
||||||
timestamp: 1727293028,
|
timestamp: 1727293028,
|
||||||
prev_id: HexBytes::<32>(hex!(
|
prev_id: Hex::<32>(hex!(
|
||||||
"41b56c273d69def3294e56179de71c61808042d54c1e085078d21dbe99e81b6f"
|
"41b56c273d69def3294e56179de71c61808042d54c1e085078d21dbe99e81b6f"
|
||||||
)),
|
)),
|
||||||
nonce: 311,
|
nonce: 311,
|
||||||
|
@ -296,10 +296,10 @@ mod test {
|
||||||
amount: 601012280000,
|
amount: 601012280000,
|
||||||
target: Target::TaggedKey {
|
target: Target::TaggedKey {
|
||||||
tagged_key: TaggedKey {
|
tagged_key: TaggedKey {
|
||||||
key: HexBytes::<32>(hex!(
|
key: Hex::<32>(hex!(
|
||||||
"8c0b16c6df02b9944b49f375d96a958a0fc5431c048879bb5bf25f64a1163b9e"
|
"8c0b16c6df02b9944b49f375d96a958a0fc5431c048879bb5bf25f64a1163b9e"
|
||||||
)),
|
)),
|
||||||
view_tag: HexBytes::<1>(hex!("88")),
|
view_tag: Hex::<1>(hex!("88")),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
@ -312,43 +312,43 @@ mod test {
|
||||||
rct_signatures: MinerTransactionRctSignatures { r#type: 0 },
|
rct_signatures: MinerTransactionRctSignatures { r#type: 0 },
|
||||||
},
|
},
|
||||||
tx_hashes: vec![
|
tx_hashes: vec![
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"eab76986a0cbcae690d8499f0f616f783fd2c89c6f611417f18011950dbdab2e"
|
"eab76986a0cbcae690d8499f0f616f783fd2c89c6f611417f18011950dbdab2e"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"57b19aa8c2cdbb6836cf13dd1e321a67860965c12e4418f3c30f58c8899a851e"
|
"57b19aa8c2cdbb6836cf13dd1e321a67860965c12e4418f3c30f58c8899a851e"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"5340185432ab6b74fb21379f7e8d8f0e37f0882b2a7121fd7c08736f079e2edc"
|
"5340185432ab6b74fb21379f7e8d8f0e37f0882b2a7121fd7c08736f079e2edc"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"01dc6d31db56d68116f5294c1b4f80b33b048b5cdfefcd904f23e6c0de3daff5"
|
"01dc6d31db56d68116f5294c1b4f80b33b048b5cdfefcd904f23e6c0de3daff5"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"c9fb6a2730678203948fef2a49fa155b63f35a3649f3d32ed405a6806f3bbd56"
|
"c9fb6a2730678203948fef2a49fa155b63f35a3649f3d32ed405a6806f3bbd56"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"af965cdd2a2315baf1d4a3d242f44fe07b1fd606d5f4853c9ff546ca6c12a5af"
|
"af965cdd2a2315baf1d4a3d242f44fe07b1fd606d5f4853c9ff546ca6c12a5af"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"97bc9e047d25fae8c14ce6ec882224e7b722f5e79b62a2602a6bacebdac8547b"
|
"97bc9e047d25fae8c14ce6ec882224e7b722f5e79b62a2602a6bacebdac8547b"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"28c46992eaf10dc0cceb313c30572d023432b7bd26e85e679bc8fe419533a7bf"
|
"28c46992eaf10dc0cceb313c30572d023432b7bd26e85e679bc8fe419533a7bf"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"c32e3acde2ff2885c9cc87253b40d6827d167dfcc3022c72f27084fd98788062"
|
"c32e3acde2ff2885c9cc87253b40d6827d167dfcc3022c72f27084fd98788062"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"19e66a47f075c7cccde8a7b52803119e089e33e3a4847cace0bd1d17b0d22bab"
|
"19e66a47f075c7cccde8a7b52803119e089e33e3a4847cace0bd1d17b0d22bab"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"8e8ac560e77a1ee72e82a5eb6887adbe5979a10cd29cb2c2a3720ce87db43a70"
|
"8e8ac560e77a1ee72e82a5eb6887adbe5979a10cd29cb2c2a3720ce87db43a70"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"b7ff5141524b5cca24de6780a5dbfdf71e7de1e062fd85f557fb3b43b8e285dc"
|
"b7ff5141524b5cca24de6780a5dbfdf71e7de1e062fd85f557fb3b43b8e285dc"
|
||||||
)),
|
)),
|
||||||
HexBytes::<32>(hex!(
|
Hex::<32>(hex!(
|
||||||
"f09df0f113763ef9b9a2752ac293b478102f7cab03ef803a3d9db7585aea8912"
|
"f09df0f113763ef9b9a2752ac293b478102f7cab03ef803a3d9db7585aea8912"
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::hex::HexBytes;
|
use crate::hex::Hex;
|
||||||
|
|
||||||
/// JSON representation of an output.
|
/// JSON representation of an output.
|
||||||
#[derive(Clone, 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 Output {
|
pub struct Output {
|
||||||
pub amount: u64,
|
pub amount: u64,
|
||||||
|
@ -22,7 +22,7 @@ pub struct Output {
|
||||||
#[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 Target {
|
pub enum Target {
|
||||||
Key { key: HexBytes<32> },
|
Key { key: Hex<32> },
|
||||||
TaggedKey { tagged_key: TaggedKey },
|
TaggedKey { tagged_key: TaggedKey },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,6 @@ impl Default for Target {
|
||||||
#[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 {
|
||||||
pub key: HexBytes<32>,
|
pub key: Hex<32>,
|
||||||
pub view_tag: HexBytes<1>,
|
pub view_tag: Hex<1>,
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -24,9 +24,7 @@ pub use transaction_verification_data::{
|
||||||
CachedVerificationState, TransactionVerificationData, TxVersion,
|
CachedVerificationState, TransactionVerificationData, TxVersion,
|
||||||
};
|
};
|
||||||
pub use types::{
|
pub use types::{
|
||||||
AddAuxPow, AltBlockInformation, AuxPow, Chain, ChainId, ChainInfo, CoinbaseTxSum,
|
AltBlockInformation, Chain, ChainId, ExtendedBlockHeader, OutputOnChain, TxsInBlock,
|
||||||
ExtendedBlockHeader, FeeEstimate, HardForkInfo, MinerData, MinerDataTxBacklogEntry,
|
|
||||||
OutputHistogramEntry, OutputHistogramInput, OutputOnChain, TxsInBlock,
|
|
||||||
VerifiedBlockInformation, VerifiedTransactionInformation,
|
VerifiedBlockInformation, VerifiedTransactionInformation,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,4 +38,10 @@ pub mod json;
|
||||||
#[cfg(feature = "hex")]
|
#[cfg(feature = "hex")]
|
||||||
pub mod hex;
|
pub mod hex;
|
||||||
|
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(feature = "rpc")] {
|
||||||
|
pub mod rpc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Private
|
//---------------------------------------------------------------------------------------------------- Private
|
||||||
|
|
24
types/src/rpc/mod.rs
Normal file
24
types/src/rpc/mod.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//! Various types (in)directly used in RPC.
|
||||||
|
//!
|
||||||
|
//! These types map very closely to types within `cuprate-rpc-types`,
|
||||||
|
//! however they use more canonical types when appropriate, for example,
|
||||||
|
//! instead of `hash: String`, this module's types would use something like
|
||||||
|
//! `hash: [u8; 32]`.
|
||||||
|
//!
|
||||||
|
//! - TODO: finish making fields canonical after <https://github.com/Cuprate/cuprate/pull/355>
|
||||||
|
//! - TODO: can epee handle `u128`? there are a lot of `(top_64 | low_64)` fields
|
||||||
|
|
||||||
|
mod pool_info;
|
||||||
|
mod pool_info_extent;
|
||||||
|
mod types;
|
||||||
|
|
||||||
|
pub use pool_info::PoolInfo;
|
||||||
|
pub use pool_info_extent::PoolInfoExtent;
|
||||||
|
pub use types::{
|
||||||
|
AddAuxPow, AuxPow, BlockHeader, BlockOutputIndices, ChainInfo, CoinbaseTxSum, ConnectionInfo,
|
||||||
|
FeeEstimate, GetBan, GetMinerDataTxBacklogEntry, GetOutputsOut, HardForkInfo, HardforkEntry,
|
||||||
|
HistogramEntry, MinerData, MinerDataTxBacklogEntry, OutKey, OutKeyBin, OutputDistributionData,
|
||||||
|
OutputHistogramEntry, OutputHistogramInput, Peer, PoolInfoFull, PoolInfoIncremental,
|
||||||
|
PoolTxInfo, PublicNode, SetBan, Span, SpentKeyImageInfo, SyncInfoPeer, TxBacklogEntry, TxInfo,
|
||||||
|
TxOutputIndices, TxpoolHisto, TxpoolStats,
|
||||||
|
};
|
|
@ -2,25 +2,20 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
use crate::misc::PoolInfoExtent;
|
use crate::rpc::PoolInfoExtent;
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
use cuprate_epee_encoding::{
|
use cuprate_epee_encoding::{
|
||||||
epee_object, error,
|
error,
|
||||||
macros::bytes::{Buf, BufMut},
|
macros::bytes::{Buf, BufMut},
|
||||||
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder,
|
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
use cuprate_fixed_bytes::ByteArrayVec;
|
use cuprate_fixed_bytes::ByteArrayVec;
|
||||||
|
|
||||||
use crate::misc::PoolTxInfo;
|
use crate::rpc::{PoolInfoFull, PoolInfoIncremental, PoolTxInfo};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- PoolInfo
|
//---------------------------------------------------------------------------------------------------- PoolInfo
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
/// Used in RPC's `get_blocks.bin`.
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
|
||||||
223..=228
|
|
||||||
)]
|
|
||||||
/// Used in [`crate::bin::GetBlocksResponse`].
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
@ -31,39 +26,6 @@ pub enum PoolInfo {
|
||||||
Full(PoolInfoFull),
|
Full(PoolInfoFull),
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Internal data
|
|
||||||
/// Data within [`PoolInfo::Incremental`].
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
#[derive(Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct PoolInfoIncremental {
|
|
||||||
pub added_pool_txs: Vec<PoolTxInfo>,
|
|
||||||
pub remaining_added_pool_txids: ByteArrayVec<32>,
|
|
||||||
pub removed_pool_txids: ByteArrayVec<32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
|
||||||
epee_object! {
|
|
||||||
PoolInfoIncremental,
|
|
||||||
added_pool_txs: Vec<PoolTxInfo>,
|
|
||||||
remaining_added_pool_txids: ByteArrayVec<32>,
|
|
||||||
removed_pool_txids: ByteArrayVec<32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Data within [`PoolInfo::Full`].
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
#[derive(Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct PoolInfoFull {
|
|
||||||
pub added_pool_txs: Vec<PoolTxInfo>,
|
|
||||||
pub remaining_added_pool_txids: ByteArrayVec<32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
|
||||||
epee_object! {
|
|
||||||
PoolInfoFull,
|
|
||||||
added_pool_txs: Vec<PoolTxInfo>,
|
|
||||||
remaining_added_pool_txids: ByteArrayVec<32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- PoolInfo epee impl
|
//---------------------------------------------------------------------------------------------------- PoolInfo epee impl
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
/// [`EpeeObjectBuilder`] for [`GetBlocksResponse`].
|
/// [`EpeeObjectBuilder`] for [`GetBlocksResponse`].
|
|
@ -12,12 +12,7 @@ use cuprate_epee_encoding::{
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- PoolInfoExtent
|
//---------------------------------------------------------------------------------------------------- PoolInfoExtent
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
/// Used in RPC's `get_blocks.bin`.
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
|
||||||
223..=228
|
|
||||||
)]
|
|
||||||
/// Used in [`crate::bin::GetBlocksResponse`].
|
|
||||||
#[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))]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
|
@ -1,26 +1,44 @@
|
||||||
//! Miscellaneous types.
|
//! Various types (in)directly used in RPC.
|
||||||
//!
|
|
||||||
//! These are `struct`s that appear in request/response types.
|
|
||||||
//! For example, [`crate::json::GetConnectionsResponse`] contains
|
|
||||||
//! the [`crate::misc::ConnectionInfo`] struct defined here.
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
use cuprate_fixed_bytes::ByteArrayVec;
|
||||||
#[cfg(feature = "serde")]
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
use crate::{hex::Hex, AddressType, ConnectionState, HardFork};
|
||||||
use cuprate_epee_encoding::epee_object;
|
|
||||||
|
|
||||||
#[cfg(any(feature = "epee", feature = "serde"))]
|
const fn default_string() -> String {
|
||||||
use crate::defaults::default_zero;
|
String::new()
|
||||||
|
}
|
||||||
|
|
||||||
use crate::macros::monero_definition_link;
|
fn default_zero<T: From<u8>>() -> T {
|
||||||
|
T::from(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Output a string link to `monerod` source code.
|
||||||
|
macro_rules! monero_definition_link {
|
||||||
|
(
|
||||||
|
$commit:literal, // Git commit hash
|
||||||
|
$file_path:literal, // File path within `monerod`'s `src/`, e.g. `rpc/core_rpc_server_commands_defs.h`
|
||||||
|
$start:literal$(..=$end:literal)? // File lines, e.g. `0..=123` or `0`
|
||||||
|
) => {
|
||||||
|
concat!(
|
||||||
|
"[Definition](https://github.com/monero-project/monero/blob/",
|
||||||
|
stringify!($commit),
|
||||||
|
"/src/",
|
||||||
|
$file_path,
|
||||||
|
"#L",
|
||||||
|
stringify!($start),
|
||||||
|
$(
|
||||||
|
"-L",
|
||||||
|
stringify!($end),
|
||||||
|
)?
|
||||||
|
")."
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Macros
|
|
||||||
/// This macro (local to this file) defines all the misc types.
|
/// This macro (local to this file) defines all the misc types.
|
||||||
///
|
///
|
||||||
/// This macro:
|
/// This macro:
|
||||||
/// 1. Defines a `pub struct` with all `pub` fields
|
/// 1. Defines a `struct` with all `pub` fields
|
||||||
/// 2. Implements `serde` on the struct
|
/// 2. Implements `serde` on the struct
|
||||||
/// 3. Implements `epee` on the struct
|
/// 3. Implements `epee` on the struct
|
||||||
///
|
///
|
||||||
|
@ -28,7 +46,7 @@ use crate::macros::monero_definition_link;
|
||||||
/// - The original Monero definition site with [`monero_definition_link`]
|
/// - The original Monero definition site with [`monero_definition_link`]
|
||||||
/// - The request/responses where the `struct` is used
|
/// - The request/responses where the `struct` is used
|
||||||
macro_rules! define_struct_and_impl_epee {
|
macro_rules! define_struct_and_impl_epee {
|
||||||
(
|
($(
|
||||||
// Optional `struct` attributes.
|
// Optional `struct` attributes.
|
||||||
$( #[$struct_attr:meta] )*
|
$( #[$struct_attr:meta] )*
|
||||||
// The `struct`'s name.
|
// The `struct`'s name.
|
||||||
|
@ -40,77 +58,65 @@ macro_rules! define_struct_and_impl_epee {
|
||||||
$field_name:ident: $field_type:ty $(= $field_default:expr_2021)?,
|
$field_name:ident: $field_type:ty $(= $field_default:expr_2021)?,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
)*) => {
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
$(
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
$( #[$struct_attr] )*
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct $struct_name {
|
$( #[$struct_attr] )*
|
||||||
$(
|
pub struct $struct_name {
|
||||||
$( #[$field_attr] )*
|
$(
|
||||||
pub $field_name: $field_type,
|
$( #[$field_attr] )*
|
||||||
)*
|
pub $field_name: $field_type,
|
||||||
}
|
)*
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
epee_object! {
|
cuprate_epee_encoding::epee_object! {
|
||||||
$struct_name,
|
$struct_name,
|
||||||
$(
|
$(
|
||||||
$field_name: $field_type $(= $field_default)?,
|
$field_name: $field_type $(= $field_default)?,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
)*
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Type Definitions
|
|
||||||
define_struct_and_impl_epee! {
|
define_struct_and_impl_epee! {
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1163..=1212
|
1163..=1212
|
||||||
)]
|
)]
|
||||||
///
|
|
||||||
/// Used in:
|
|
||||||
/// - [`crate::json::GetLastBlockHeaderResponse`]
|
|
||||||
/// - [`crate::json::GetBlockHeaderByHashResponse`]
|
|
||||||
/// - [`crate::json::GetBlockHeaderByHeightResponse`]
|
|
||||||
/// - [`crate::json::GetBlockHeadersRangeResponse`]
|
|
||||||
/// - [`crate::json::GetBlockResponse`]
|
|
||||||
BlockHeader {
|
BlockHeader {
|
||||||
block_size: u64,
|
|
||||||
block_weight: u64,
|
block_weight: u64,
|
||||||
cumulative_difficulty_top64: u64,
|
cumulative_difficulty_top64: u64,
|
||||||
cumulative_difficulty: u64,
|
cumulative_difficulty: u64,
|
||||||
depth: u64,
|
depth: u64,
|
||||||
difficulty_top64: u64,
|
difficulty_top64: u64,
|
||||||
difficulty: u64,
|
difficulty: u64,
|
||||||
hash: String,
|
hash: [u8; 32],
|
||||||
height: u64,
|
height: u64,
|
||||||
long_term_weight: u64,
|
long_term_weight: u64,
|
||||||
major_version: u8,
|
major_version: HardFork,
|
||||||
miner_tx_hash: String,
|
miner_tx_hash: [u8; 32],
|
||||||
minor_version: u8,
|
minor_version: u8,
|
||||||
nonce: u32,
|
nonce: u32,
|
||||||
num_txes: u64,
|
num_txes: u64,
|
||||||
orphan_status: bool,
|
orphan_status: bool,
|
||||||
pow_hash: String,
|
pow_hash: [u8; 32],
|
||||||
prev_hash: String,
|
prev_hash: [u8; 32],
|
||||||
reward: u64,
|
reward: u64,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
wide_cumulative_difficulty: String,
|
|
||||||
wide_difficulty: String,
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"cryptonote_protocol/cryptonote_protocol_defs.h",
|
"cryptonote_protocol/cryptonote_protocol_defs.h",
|
||||||
47..=116
|
47..=116
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::json::GetConnectionsResponse`].
|
|
||||||
ConnectionInfo {
|
ConnectionInfo {
|
||||||
address: String,
|
address: String,
|
||||||
address_type: cuprate_types::AddressType,
|
address_type: AddressType,
|
||||||
avg_download: u64,
|
avg_download: u64,
|
||||||
avg_upload: u64,
|
avg_upload: u64,
|
||||||
connection_id: String,
|
connection_id: String,
|
||||||
|
@ -135,110 +141,88 @@ define_struct_and_impl_epee! {
|
||||||
// Exists in the original definition, but isn't
|
// Exists in the original definition, but isn't
|
||||||
// used or (de)serialized for RPC purposes.
|
// used or (de)serialized for RPC purposes.
|
||||||
// ssl: bool,
|
// ssl: bool,
|
||||||
state: cuprate_types::ConnectionState,
|
state: ConnectionState,
|
||||||
support_flags: u32,
|
support_flags: u32,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
2034..=2047
|
2034..=2047
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::json::SetBansRequest`].
|
|
||||||
SetBan {
|
SetBan {
|
||||||
#[cfg_attr(feature = "serde", serde(default = "crate::defaults::default_string"))]
|
#[cfg_attr(feature = "serde", serde(default = "default_string"))]
|
||||||
host: String,
|
host: String,
|
||||||
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
ip: u32,
|
ip: u32,
|
||||||
ban: bool,
|
ban: bool,
|
||||||
seconds: u32,
|
seconds: u32,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1999..=2010
|
1999..=2010
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::json::GetBansResponse`].
|
|
||||||
GetBan {
|
GetBan {
|
||||||
host: String,
|
host: String,
|
||||||
ip: u32,
|
ip: u32,
|
||||||
seconds: u32,
|
seconds: u32,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
2139..=2156
|
2139..=2156
|
||||||
)]
|
)]
|
||||||
#[derive(Copy)]
|
#[derive(Copy)]
|
||||||
/// Used in [`crate::json::GetOutputHistogramResponse`].
|
|
||||||
HistogramEntry {
|
HistogramEntry {
|
||||||
amount: u64,
|
amount: u64,
|
||||||
total_instances: u64,
|
total_instances: u64,
|
||||||
unlocked_instances: u64,
|
unlocked_instances: u64,
|
||||||
recent_instances: u64,
|
recent_instances: u64,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
2180..=2191
|
2180..=2191
|
||||||
)]
|
)]
|
||||||
#[derive(Copy)]
|
#[derive(Copy)]
|
||||||
/// Used in [`crate::json::GetVersionResponse`].
|
|
||||||
HardforkEntry {
|
HardforkEntry {
|
||||||
height: u64,
|
height: u64,
|
||||||
hf_version: u8,
|
hf_version: HardFork,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
2289..=2310
|
2289..=2310
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::json::GetAlternateChainsResponse`].
|
|
||||||
ChainInfo {
|
ChainInfo {
|
||||||
block_hash: String,
|
block_hash: [u8; 32],
|
||||||
block_hashes: Vec<String>,
|
block_hashes: Vec<[u8; 32]>,
|
||||||
difficulty: u64,
|
|
||||||
difficulty_top64: u64,
|
difficulty_top64: u64,
|
||||||
|
difficulty: u64,
|
||||||
height: u64,
|
height: u64,
|
||||||
length: u64,
|
length: u64,
|
||||||
main_chain_parent_block: String,
|
main_chain_parent_block: [u8; 32],
|
||||||
wide_difficulty: String,
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
2393..=2400
|
2393..=2400
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::json::SyncInfoResponse`].
|
|
||||||
SyncInfoPeer {
|
SyncInfoPeer {
|
||||||
info: ConnectionInfo,
|
info: ConnectionInfo,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
2402..=2421
|
2402..=2421
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::json::SyncInfoResponse`].
|
|
||||||
Span {
|
Span {
|
||||||
connection_id: String,
|
connection_id: String,
|
||||||
nblocks: u64,
|
nblocks: u64,
|
||||||
|
@ -248,129 +232,85 @@ define_struct_and_impl_epee! {
|
||||||
speed: u32,
|
speed: u32,
|
||||||
start_block_height: u64,
|
start_block_height: u64,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1637..=1642
|
1637..=1642
|
||||||
)]
|
)]
|
||||||
#[derive(Copy)]
|
#[derive(Copy)]
|
||||||
/// Used in [`crate::json::GetTransactionPoolBacklogResponse`].
|
|
||||||
TxBacklogEntry {
|
TxBacklogEntry {
|
||||||
weight: u64,
|
weight: u64,
|
||||||
fee: u64,
|
fee: u64,
|
||||||
time_in_pool: u64,
|
time_in_pool: u64,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/rpc_handler.h",
|
"rpc/rpc_handler.h",
|
||||||
45..=50
|
45..=50
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::json::GetOutputDistributionResponse`].
|
|
||||||
OutputDistributionData {
|
OutputDistributionData {
|
||||||
distribution: Vec<u64>,
|
distribution: Vec<u64>,
|
||||||
start_height: u64,
|
start_height: u64,
|
||||||
base: u64,
|
base: u64,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1016..=1027
|
1016..=1027
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::json::GetMinerDataResponse`].
|
|
||||||
///
|
|
||||||
/// Note that this is different than [`crate::misc::TxBacklogEntry`].
|
|
||||||
GetMinerDataTxBacklogEntry {
|
GetMinerDataTxBacklogEntry {
|
||||||
id: String,
|
id: String,
|
||||||
weight: u64,
|
weight: u64,
|
||||||
fee: u64,
|
fee: u64,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1070..=1079
|
1070..=1079
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::json::AddAuxPowRequest`].
|
|
||||||
AuxPow {
|
AuxPow {
|
||||||
id: String,
|
id: [u8; 32],
|
||||||
hash: String,
|
hash: [u8; 32],
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
192..=199
|
192..=199
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::bin::GetBlocksResponse`].
|
|
||||||
TxOutputIndices {
|
TxOutputIndices {
|
||||||
indices: Vec<u64>,
|
indices: Vec<u64>,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
201..=208
|
201..=208
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::bin::GetBlocksResponse`].
|
|
||||||
BlockOutputIndices {
|
BlockOutputIndices {
|
||||||
indices: Vec<TxOutputIndices>,
|
indices: Vec<TxOutputIndices>,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
|
||||||
210..=221
|
|
||||||
)]
|
|
||||||
/// Used in [`crate::bin::GetBlocksResponse`].
|
|
||||||
PoolTxInfo {
|
|
||||||
tx_hash: [u8; 32],
|
|
||||||
tx_blob: String,
|
|
||||||
double_spend_seen: bool,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
512..=521
|
512..=521
|
||||||
)]
|
)]
|
||||||
#[derive(Copy)]
|
#[derive(Copy)]
|
||||||
///
|
|
||||||
/// Used in:
|
|
||||||
/// - [`crate::bin::GetOutsRequest`]
|
|
||||||
/// - [`crate::other::GetOutsRequest`]
|
|
||||||
GetOutputsOut {
|
GetOutputsOut {
|
||||||
amount: u64,
|
amount: u64,
|
||||||
index: u64,
|
index: u64,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
538..=553
|
538..=553
|
||||||
)]
|
)]
|
||||||
#[derive(Copy)]
|
|
||||||
/// Used in [`crate::bin::GetOutsRequest`].
|
|
||||||
OutKeyBin {
|
OutKeyBin {
|
||||||
key: [u8; 32],
|
key: [u8; 32],
|
||||||
mask: [u8; 32],
|
mask: [u8; 32],
|
||||||
|
@ -378,15 +318,12 @@ define_struct_and_impl_epee! {
|
||||||
height: u64,
|
height: u64,
|
||||||
txid: [u8; 32],
|
txid: [u8; 32],
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1335..=1367
|
1335..=1367
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::other::GetPeerListResponse`].
|
|
||||||
Peer {
|
Peer {
|
||||||
id: u64,
|
id: u64,
|
||||||
host: String,
|
host: String,
|
||||||
|
@ -400,88 +337,70 @@ define_struct_and_impl_epee! {
|
||||||
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
pruning_seed: u32 = default_zero::<u32>(),
|
pruning_seed: u32 = default_zero::<u32>(),
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1398..=1417
|
1398..=1417
|
||||||
)]
|
)]
|
||||||
///
|
|
||||||
/// Used in:
|
|
||||||
/// - [`crate::other::GetPeerListResponse`]
|
|
||||||
/// - [`crate::other::GetPublicNodesResponse`]
|
|
||||||
PublicNode {
|
PublicNode {
|
||||||
host: String,
|
host: String,
|
||||||
last_seen: u64,
|
last_seen: u64,
|
||||||
rpc_port: u16,
|
rpc_port: u16,
|
||||||
rpc_credits_per_hash: u32,
|
rpc_credits_per_hash: u32,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1519..=1556
|
1519..=1556
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::other::GetTransactionPoolResponse`].
|
|
||||||
TxInfo {
|
TxInfo {
|
||||||
blob_size: u64,
|
blob_size: u64,
|
||||||
do_not_relay: bool,
|
do_not_relay: bool,
|
||||||
double_spend_seen: bool,
|
double_spend_seen: bool,
|
||||||
fee: u64,
|
fee: u64,
|
||||||
id_hash: String,
|
id_hash: [u8; 32],
|
||||||
kept_by_block: bool,
|
kept_by_block: bool,
|
||||||
last_failed_height: u64,
|
last_failed_height: u64,
|
||||||
last_failed_id_hash: String,
|
last_failed_id_hash: [u8; 32],
|
||||||
last_relayed_time: u64,
|
last_relayed_time: u64,
|
||||||
max_used_block_height: u64,
|
max_used_block_height: u64,
|
||||||
max_used_block_id_hash: String,
|
max_used_block_id_hash: [u8; 32],
|
||||||
receive_time: u64,
|
receive_time: u64,
|
||||||
relayed: bool,
|
relayed: bool,
|
||||||
tx_blob: String,
|
tx_blob: Vec<u8>,
|
||||||
tx_json: String, // TODO: this should be another struct
|
tx_json: crate::json::tx::Transaction,
|
||||||
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
weight: u64 = default_zero::<u64>(),
|
weight: u64 = default_zero::<u64>(),
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1558..=1567
|
1558..=1567
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::other::GetTransactionPoolResponse`].
|
|
||||||
SpentKeyImageInfo {
|
SpentKeyImageInfo {
|
||||||
id_hash: String,
|
id_hash: String,
|
||||||
txs_hashes: Vec<String>,
|
txs_hashes: Vec<String>,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1666..=1675
|
1666..=1675
|
||||||
)]
|
)]
|
||||||
#[derive(Copy)]
|
#[derive(Copy)]
|
||||||
/// Used in [`crate::other::GetTransactionPoolStatsResponse`].
|
|
||||||
TxpoolHisto {
|
TxpoolHisto {
|
||||||
txs: u32,
|
txs: u32,
|
||||||
bytes: u64,
|
bytes: u64,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
1677..=1710
|
1677..=1710
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::other::GetTransactionPoolStatsResponse`].
|
|
||||||
TxpoolStats {
|
TxpoolStats {
|
||||||
bytes_max: u32,
|
bytes_max: u32,
|
||||||
bytes_med: u32,
|
bytes_med: u32,
|
||||||
|
@ -497,24 +416,160 @@ define_struct_and_impl_epee! {
|
||||||
oldest: u64,
|
oldest: u64,
|
||||||
txs_total: u32,
|
txs_total: u32,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
582..=597
|
582..=597
|
||||||
)]
|
)]
|
||||||
/// Used in [`crate::other::GetOutsResponse`].
|
|
||||||
OutKey {
|
OutKey {
|
||||||
key: String,
|
key: Hex<32>,
|
||||||
mask: String,
|
mask: Hex<32>,
|
||||||
unlocked: bool,
|
unlocked: bool,
|
||||||
height: u64,
|
height: u64,
|
||||||
txid: String,
|
txid: Hex<32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"blockchain_db/lmdb/db_lmdb.cpp",
|
||||||
|
4222
|
||||||
|
)]
|
||||||
|
OutputHistogramInput {
|
||||||
|
amounts: Vec<u64>,
|
||||||
|
min_count: u64,
|
||||||
|
max_count: u64,
|
||||||
|
unlocked: bool,
|
||||||
|
recent_cutoff: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2139..=2156
|
||||||
|
)]
|
||||||
|
OutputHistogramEntry {
|
||||||
|
amount: u64,
|
||||||
|
total_instances: u64,
|
||||||
|
unlocked_instances: u64,
|
||||||
|
recent_instances: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2228..=2247
|
||||||
|
)]
|
||||||
|
CoinbaseTxSum {
|
||||||
|
emission_amount_top64: u64,
|
||||||
|
emission_amount: u64,
|
||||||
|
fee_amount_top64: u64,
|
||||||
|
fee_amount: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1027..=1033
|
||||||
|
)]
|
||||||
|
MinerData {
|
||||||
|
major_version: u8,
|
||||||
|
height: u64,
|
||||||
|
prev_id: [u8; 32],
|
||||||
|
seed_hash: [u8; 32],
|
||||||
|
difficulty_top64: u64,
|
||||||
|
difficulty: u64,
|
||||||
|
median_weight: u64,
|
||||||
|
already_generated_coins: u64,
|
||||||
|
tx_backlog: Vec<MinerDataTxBacklogEntry>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1037..=1039
|
||||||
|
)]
|
||||||
|
MinerDataTxBacklogEntry {
|
||||||
|
id: [u8; 32],
|
||||||
|
weight: u64,
|
||||||
|
fee: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1973..=1980
|
||||||
|
)]
|
||||||
|
HardForkInfo {
|
||||||
|
earliest_height: u64,
|
||||||
|
enabled: bool,
|
||||||
|
state: u32,
|
||||||
|
threshold: u32,
|
||||||
|
version: u8,
|
||||||
|
votes: u32,
|
||||||
|
voting: u8,
|
||||||
|
window: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2264..=2267
|
||||||
|
)]
|
||||||
|
FeeEstimate {
|
||||||
|
fee: u64,
|
||||||
|
fees: Vec<u64>,
|
||||||
|
quantization_mask: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1115..=1119
|
||||||
|
)]
|
||||||
|
AddAuxPow {
|
||||||
|
blocktemplate_blob: Vec<u8>,
|
||||||
|
blockhashing_blob: Vec<u8>,
|
||||||
|
merkle_root: [u8; 32],
|
||||||
|
merkle_tree_depth: u64,
|
||||||
|
aux_pow: Vec<AuxPow>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
227..=229
|
||||||
|
)]
|
||||||
|
PoolTxInfo {
|
||||||
|
tx_hash: [u8; 32],
|
||||||
|
tx_blob: Vec<u8>,
|
||||||
|
double_spend_seen: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
254..=256
|
||||||
|
)]
|
||||||
|
PoolInfoIncremental {
|
||||||
|
added_pool_txs: Vec<PoolTxInfo>,
|
||||||
|
remaining_added_pool_txids: ByteArrayVec<32>,
|
||||||
|
removed_pool_txids: ByteArrayVec<32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
254..=256
|
||||||
|
)]
|
||||||
|
PoolInfoFull {
|
||||||
|
added_pool_txs: Vec<PoolTxInfo>,
|
||||||
|
remaining_added_pool_txids: ByteArrayVec<32>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Tests
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {}
|
mod test {
|
||||||
|
// use super::*;
|
||||||
|
}
|
|
@ -147,118 +147,6 @@ pub struct OutputOnChain {
|
||||||
pub commitment: EdwardsPoint,
|
pub commitment: EdwardsPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Input required to generate an output histogram.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_output_histogram`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct OutputHistogramInput {
|
|
||||||
pub amounts: Vec<u64>,
|
|
||||||
pub min_count: u64,
|
|
||||||
pub max_count: u64,
|
|
||||||
pub unlocked: bool,
|
|
||||||
pub recent_cutoff: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A single entry in an output histogram.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_output_histogram`.
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct OutputHistogramEntry {
|
|
||||||
pub amount: u64,
|
|
||||||
pub total_instances: u64,
|
|
||||||
pub unlocked_instances: u64,
|
|
||||||
pub recent_instances: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Data of summed coinbase transactions.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_coinbase_tx_sum`.
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct CoinbaseTxSum {
|
|
||||||
pub emission_amount: u128,
|
|
||||||
pub fee_amount: u128,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Data to create a custom block template.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_miner_data`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct MinerData {
|
|
||||||
pub major_version: u8,
|
|
||||||
pub height: u64,
|
|
||||||
pub prev_id: [u8; 32],
|
|
||||||
pub seed_hash: [u8; 32],
|
|
||||||
pub difficulty: u128,
|
|
||||||
pub median_weight: u64,
|
|
||||||
pub already_generated_coins: u64,
|
|
||||||
pub tx_backlog: Vec<MinerDataTxBacklogEntry>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A transaction in the txpool.
|
|
||||||
///
|
|
||||||
/// Used in [`MinerData::tx_backlog`].
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct MinerDataTxBacklogEntry {
|
|
||||||
pub id: [u8; 32],
|
|
||||||
pub weight: u64,
|
|
||||||
pub fee: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Information on a [`HardFork`].
|
|
||||||
///
|
|
||||||
/// Used in RPC's `hard_fork_info`.
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct HardForkInfo {
|
|
||||||
pub earliest_height: u64,
|
|
||||||
pub enabled: bool,
|
|
||||||
pub state: u32,
|
|
||||||
pub threshold: u32,
|
|
||||||
pub version: u8,
|
|
||||||
pub votes: u32,
|
|
||||||
pub voting: u8,
|
|
||||||
pub window: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Estimated fee data.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_fee_estimate`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct FeeEstimate {
|
|
||||||
pub fee: u64,
|
|
||||||
pub fees: Vec<u64>,
|
|
||||||
pub quantization_mask: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Information on a (maybe alternate) chain.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_alternate_chains`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct ChainInfo {
|
|
||||||
pub block_hash: [u8; 32],
|
|
||||||
pub block_hashes: Vec<[u8; 32]>,
|
|
||||||
pub difficulty: u128,
|
|
||||||
pub height: u64,
|
|
||||||
pub length: u64,
|
|
||||||
pub main_chain_parent_block: [u8; 32],
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Used in RPC's `add_aux_pow`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct AuxPow {
|
|
||||||
pub id: [u8; 32],
|
|
||||||
pub hash: [u8; 32],
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Used in RPC's `add_aux_pow`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct AddAuxPow {
|
|
||||||
pub blocktemplate_blob: Vec<u8>,
|
|
||||||
pub blockhashing_blob: Vec<u8>,
|
|
||||||
pub merkle_root: [u8; 32],
|
|
||||||
pub merkle_tree_depth: u64,
|
|
||||||
pub aux_pow: Vec<AuxPow>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The inner response for a request for txs in a block.
|
/// The inner response for a request for txs in a block.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct TxsInBlock {
|
pub struct TxsInBlock {
|
||||||
|
|
|
@ -5,9 +5,11 @@
|
||||||
//! * `json-full-chain_main` (`Vec<ChainMain>`)
|
//! * `json-full-chain_main` (`Vec<ChainMain>`)
|
||||||
//! * `json-minimal-chain_main` (`ChainMainMin`)
|
//! * `json-minimal-chain_main` (`ChainMainMin`)
|
||||||
//! * `json-full-miner_data` (`MinerData`)
|
//! * `json-full-miner_data` (`MinerData`)
|
||||||
use cuprate_types::hex::HexBytes;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use cuprate_types::hex::Hex;
|
||||||
|
|
||||||
/// ZMQ `json-full-txpool_add` packets contain an array of `TxPoolAdd`.
|
/// ZMQ `json-full-txpool_add` packets contain an array of `TxPoolAdd`.
|
||||||
///
|
///
|
||||||
/// Each `TxPoolAdd` object represents a new transaction in the mempool that was
|
/// Each `TxPoolAdd` object represents a new transaction in the mempool that was
|
||||||
|
@ -42,7 +44,7 @@ pub struct TxPoolAdd {
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
pub struct TxPoolAddMin {
|
pub struct TxPoolAddMin {
|
||||||
/// transaction ID
|
/// transaction ID
|
||||||
pub id: HexBytes<32>,
|
pub id: Hex<32>,
|
||||||
/// size of the full transaction blob
|
/// size of the full transaction blob
|
||||||
pub blob_size: u64,
|
pub blob_size: u64,
|
||||||
/// metric used to calculate transaction fee
|
/// metric used to calculate transaction fee
|
||||||
|
@ -63,13 +65,13 @@ pub struct ChainMain {
|
||||||
/// epoch time, decided by the miner, at which the block was mined
|
/// epoch time, decided by the miner, at which the block was mined
|
||||||
pub timestamp: u64,
|
pub timestamp: u64,
|
||||||
/// block id of the previous block
|
/// block id of the previous block
|
||||||
pub prev_id: HexBytes<32>,
|
pub prev_id: Hex<32>,
|
||||||
/// cryptographic random one-time number used in mining a Monero block
|
/// cryptographic random one-time number used in mining a Monero block
|
||||||
pub nonce: u32,
|
pub nonce: u32,
|
||||||
/// coinbase transaction information
|
/// coinbase transaction information
|
||||||
pub miner_tx: MinerTx,
|
pub miner_tx: MinerTx,
|
||||||
/// non-coinbase transaction IDs in the block (can be empty)
|
/// non-coinbase transaction IDs in the block (can be empty)
|
||||||
pub tx_hashes: Vec<HexBytes<32>>,
|
pub tx_hashes: Vec<Hex<32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ZMQ `json-minimal-chain_main` subscriber messages contain a single
|
/// ZMQ `json-minimal-chain_main` subscriber messages contain a single
|
||||||
|
@ -80,10 +82,10 @@ pub struct ChainMainMin {
|
||||||
/// height of the block
|
/// height of the block
|
||||||
pub first_height: u64,
|
pub first_height: u64,
|
||||||
/// block id of the previous block
|
/// block id of the previous block
|
||||||
pub first_prev_id: HexBytes<32>,
|
pub first_prev_id: Hex<32>,
|
||||||
/// block ID of the current block is the 0th entry; additional block IDs
|
/// block ID of the current block is the 0th entry; additional block IDs
|
||||||
/// will only be included if this is the topmost block of a re-org.
|
/// will only be included if this is the topmost block of a re-org.
|
||||||
pub ids: Vec<HexBytes<32>>,
|
pub ids: Vec<Hex<32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ZMQ `json-full-miner_data` subscriber messages contain a single
|
/// ZMQ `json-full-miner_data` subscriber messages contain a single
|
||||||
|
@ -96,9 +98,9 @@ pub struct MinerData {
|
||||||
/// height on which to mine
|
/// height on which to mine
|
||||||
pub height: u64,
|
pub height: u64,
|
||||||
/// block id of the most recent block on which to mine the next block
|
/// block id of the most recent block on which to mine the next block
|
||||||
pub prev_id: HexBytes<32>,
|
pub prev_id: Hex<32>,
|
||||||
/// hash of block to use as seed for Random-X proof-of-work
|
/// hash of block to use as seed for Random-X proof-of-work
|
||||||
pub seed_hash: HexBytes<32>,
|
pub seed_hash: Hex<32>,
|
||||||
/// least-significant 64 bits of the 128-bit network difficulty
|
/// least-significant 64 bits of the 128-bit network difficulty
|
||||||
#[serde(with = "hex_difficulty")]
|
#[serde(with = "hex_difficulty")]
|
||||||
pub difficulty: u64,
|
pub difficulty: u64,
|
||||||
|
@ -124,7 +126,7 @@ pub struct ToKey {
|
||||||
/// integer offsets for ring members
|
/// integer offsets for ring members
|
||||||
pub key_offsets: Vec<u64>,
|
pub key_offsets: Vec<u64>,
|
||||||
/// key image for the given input
|
/// key image for the given input
|
||||||
pub key_image: HexBytes<32>,
|
pub key_image: Hex<32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Holds the block height of the coinbase transaction.
|
/// Holds the block height of the coinbase transaction.
|
||||||
|
@ -156,9 +158,9 @@ pub struct Output {
|
||||||
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
|
||||||
pub struct ToTaggedKey {
|
pub struct ToTaggedKey {
|
||||||
/// public key used to indicate the destination of a transaction output
|
/// public key used to indicate the destination of a transaction output
|
||||||
pub key: HexBytes<32>,
|
pub key: Hex<32>,
|
||||||
/// 1st byte of a shared secret used to reduce wallet synchronization time
|
/// 1st byte of a shared secret used to reduce wallet synchronization time
|
||||||
pub view_tag: HexBytes<1>,
|
pub view_tag: Hex<1>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ring CT information used inside `TxPoolAdd`
|
/// Ring CT information used inside `TxPoolAdd`
|
||||||
|
@ -169,7 +171,7 @@ pub struct PoolRingCt {
|
||||||
/// encrypted amount values of the transaction outputs
|
/// encrypted amount values of the transaction outputs
|
||||||
pub encrypted: Vec<Encrypted>,
|
pub encrypted: Vec<Encrypted>,
|
||||||
/// Ring CT commitments, 1 per transaction input
|
/// Ring CT commitments, 1 per transaction input
|
||||||
pub commitments: Vec<HexBytes<32>>,
|
pub commitments: Vec<Hex<32>>,
|
||||||
/// mining fee in piconeros
|
/// mining fee in piconeros
|
||||||
pub fee: u64,
|
pub fee: u64,
|
||||||
/// data to validate the transaction that can be pruned from older blocks
|
/// data to validate the transaction that can be pruned from older blocks
|
||||||
|
@ -189,9 +191,9 @@ struct MinerRingCt {
|
||||||
pub struct Encrypted {
|
pub struct Encrypted {
|
||||||
/// obsolete field, but present as zeros in JSON; this does not represent
|
/// obsolete field, but present as zeros in JSON; this does not represent
|
||||||
/// the newer deterministically derived mask
|
/// the newer deterministically derived mask
|
||||||
mask: HexBytes<32>,
|
mask: Hex<32>,
|
||||||
/// encrypted amount of the transaction output
|
/// encrypted amount of the transaction output
|
||||||
pub amount: HexBytes<32>,
|
pub amount: Hex<32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data needed to validate a transaction that can optionally be pruned from
|
/// Data needed to validate a transaction that can optionally be pruned from
|
||||||
|
@ -210,22 +212,22 @@ pub struct Prunable {
|
||||||
pub clsags: Vec<Clsag>,
|
pub clsags: Vec<Clsag>,
|
||||||
/// Ring CT pseudo output commitments; 1 per transaction input (*not*
|
/// Ring CT pseudo output commitments; 1 per transaction input (*not*
|
||||||
/// output)
|
/// output)
|
||||||
pub pseudo_outs: Vec<HexBytes<32>>,
|
pub pseudo_outs: Vec<Hex<32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bulletproofs+ data used to validate the legitimacy of a Ring CT transaction.
|
/// Bulletproofs+ data used to validate the legitimacy of a Ring CT transaction.
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
#[expect(non_snake_case)]
|
#[expect(non_snake_case)]
|
||||||
pub struct BulletproofPlus {
|
pub struct BulletproofPlus {
|
||||||
pub V: Vec<HexBytes<32>>,
|
pub V: Vec<Hex<32>>,
|
||||||
pub A: HexBytes<32>,
|
pub A: Hex<32>,
|
||||||
pub A1: HexBytes<32>,
|
pub A1: Hex<32>,
|
||||||
pub B: HexBytes<32>,
|
pub B: Hex<32>,
|
||||||
pub r1: HexBytes<32>,
|
pub r1: Hex<32>,
|
||||||
pub s1: HexBytes<32>,
|
pub s1: Hex<32>,
|
||||||
pub d1: HexBytes<32>,
|
pub d1: Hex<32>,
|
||||||
pub L: Vec<HexBytes<32>>,
|
pub L: Vec<Hex<32>>,
|
||||||
pub R: Vec<HexBytes<32>>,
|
pub R: Vec<Hex<32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Placeholder element type so obsolete fields can be deserialized
|
/// Placeholder element type so obsolete fields can be deserialized
|
||||||
|
@ -237,9 +239,9 @@ struct Obsolete;
|
||||||
#[expect(non_snake_case)]
|
#[expect(non_snake_case)]
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
pub struct Clsag {
|
pub struct Clsag {
|
||||||
pub s: Vec<HexBytes<32>>,
|
pub s: Vec<Hex<32>>,
|
||||||
pub c1: HexBytes<32>,
|
pub c1: Hex<32>,
|
||||||
pub D: HexBytes<32>,
|
pub D: Hex<32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Part of the new block information in `ChainMain`
|
/// Part of the new block information in `ChainMain`
|
||||||
|
@ -269,7 +271,7 @@ pub struct MinerTx {
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
pub struct TxBacklog {
|
pub struct TxBacklog {
|
||||||
/// transaction ID
|
/// transaction ID
|
||||||
pub id: HexBytes<32>,
|
pub id: Hex<32>,
|
||||||
/// metric used to calculate transaction fee
|
/// metric used to calculate transaction fee
|
||||||
pub weight: u64,
|
pub weight: u64,
|
||||||
/// mining fee in piconeros
|
/// mining fee in piconeros
|
||||||
|
|
Loading…
Reference in a new issue