zeldhash_protocol/
types.rs

1use bitcoin::Txid;
2
3/// 12-byte key identifying a UTXO, derived from txid and vout via xxh3-128.
4pub type UtxoKey = [u8; 12];
5
6/// ZELD balance type (unsigned 64-bit integer).
7pub type Amount = u64;
8
9/// Represents a transaction output with ZELD-relevant data.
10#[derive(Debug, Clone)]
11pub struct ZeldOutput {
12    /// Unique key identifying this UTXO.
13    pub utxo_key: UtxoKey,
14    /// Satoshi value of this output.
15    pub value: Amount,
16    /// ZELD reward assigned to this output.
17    pub reward: Amount,
18    /// Custom distribution amount from OP_RETURN (if any).
19    pub distribution: Amount,
20    /// Output index within the transaction.
21    pub vout: u32,
22}
23
24/// Represents a transaction input with ZELD-relevant data.
25#[derive(Debug, Clone)]
26pub struct ZeldInput {
27    /// Key of the UTXO being spent.
28    pub utxo_key: UtxoKey,
29}
30
31/// Pre-processed transaction with all ZELD-relevant fields.
32#[derive(Debug, Clone)]
33pub struct ZeldTransaction {
34    /// Transaction ID.
35    pub txid: Txid,
36    /// Transaction inputs.
37    pub inputs: Vec<ZeldInput>,
38    /// Transaction outputs (excluding OP_RETURN).
39    pub outputs: Vec<ZeldOutput>,
40    /// Number of leading zeros in the txid.
41    pub zero_count: u8,
42    /// Total ZELD reward for this transaction.
43    pub reward: Amount,
44    /// Whether custom distribution was specified via OP_RETURN.
45    pub has_op_return_distribution: bool,
46}
47
48/// Pre-processed block with all ZELD-relevant transactions.
49#[derive(Debug, Clone)]
50pub struct PreProcessedZeldBlock {
51    /// Transactions in the block (excluding coinbase).
52    pub transactions: Vec<ZeldTransaction>,
53    /// Highest leading zero count among all transactions.
54    pub max_zero_count: u8,
55}
56
57/// Reward information for a single rewarded output.
58#[derive(Debug, Clone)]
59pub struct Reward {
60    /// Transaction ID that produced the reward.
61    pub txid: Txid,
62    /// Output index carrying the reward.
63    pub vout: u32,
64    /// ZELD reward granted to the output.
65    pub reward: Amount,
66    /// Leading zero count of the transaction ID.
67    pub zero_count: u8,
68}
69
70/// Fully processed block statistics and reward set.
71#[derive(Debug, Clone)]
72pub struct ProcessedZeldBlock {
73    /// All rewards generated within the block.
74    pub rewards: Vec<Reward>,
75    /// Sum of all rewards in the block.
76    pub total_reward: Amount,
77    /// Highest leading zero count observed in the block.
78    pub max_zero_count: u8,
79    /// TXID of the transaction with the highest zero count.
80    pub nicest_txid: Option<Txid>,
81    /// Number of previously existing UTXOs spent in the block.
82    pub utxo_spent_count: u64,
83    /// Number of new UTXOs created in the block.
84    pub new_utxo_count: u64,
85}