1use bitcoin::{hashes::Hash, BlockHash};
2
3#[derive(Debug, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
6pub struct BlockId {
7 pub height: u32,
9 pub hash: BlockHash,
11}
12
13impl Default for BlockId {
14 fn default() -> Self {
15 Self {
16 height: Default::default(),
17 hash: BlockHash::all_zeros(),
18 }
19 }
20}
21
22impl From<(u32, BlockHash)> for BlockId {
23 fn from((height, hash): (u32, BlockHash)) -> Self {
24 Self { height, hash }
25 }
26}
27
28impl From<BlockId> for (u32, BlockHash) {
29 fn from(block_id: BlockId) -> Self {
30 (block_id.height, block_id.hash)
31 }
32}
33
34impl From<(&u32, &BlockHash)> for BlockId {
35 fn from((height, hash): (&u32, &BlockHash)) -> Self {
36 Self {
37 height: *height,
38 hash: *hash,
39 }
40 }
41}
42
43#[derive(Debug, Default, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)]
45#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
46pub struct ConfirmationBlockTime {
47 pub block_id: BlockId,
49 pub confirmation_time: u64,
51}