zebra_rpc/methods/types/
default_roots.rs

1//! The `DefaultRoots` type is part of the `getblocktemplate` RPC method output.
2
3use derive_getters::Getters;
4use derive_new::new;
5use zebra_chain::block::{
6    merkle::{self, AuthDataRoot},
7    ChainHistoryBlockTxAuthCommitmentHash, ChainHistoryMmrRootHash,
8};
9
10/// The block header roots for [`GetBlockTemplate.transactions`].
11///
12/// If the transactions in the block template are modified, these roots must be recalculated
13/// [according to the specification](https://zcash.github.io/rpc/getblocktemplate.html).
14#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, Getters, new)]
15pub struct DefaultRoots {
16    /// The merkle root of the transaction IDs in the block.
17    /// Used in the new block's header.
18    #[serde(rename = "merkleroot")]
19    #[serde(with = "hex")]
20    #[getter(copy)]
21    pub(crate) merkle_root: merkle::Root,
22
23    /// The root of the merkle mountain range of the chain history roots from the last network upgrade to the previous block.
24    /// Unlike the other roots, this not cover any data from this new block, only from previous blocks.
25    #[serde(rename = "chainhistoryroot")]
26    #[serde(with = "hex")]
27    #[getter(copy)]
28    pub(crate) chain_history_root: ChainHistoryMmrRootHash,
29
30    /// The merkle root of the authorizing data hashes of the transactions in the new block.
31    #[serde(rename = "authdataroot")]
32    #[serde(with = "hex")]
33    #[getter(copy)]
34    pub(crate) auth_data_root: AuthDataRoot,
35
36    /// The block commitment for the new block's header.
37    /// This hash covers `chain_history_root` and `auth_data_root`.
38    ///
39    /// `merkle_root` has its own field in the block header.
40    #[serde(rename = "blockcommitmentshash")]
41    #[serde(with = "hex")]
42    #[getter(copy)]
43    pub(crate) block_commitments_hash: ChainHistoryBlockTxAuthCommitmentHash,
44}