use bitcoin::block::Header as BitcoinBlockHeader;
use serde::{Serialize, Deserialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BlockHeader {
pub version: i32,
pub prev_blockhash: String,
pub merkle_root: String,
pub time: u32,
pub bits: u32,
pub nonce: u32,
}
impl From<BitcoinBlockHeader> for BlockHeader {
fn from(header: BitcoinBlockHeader) -> Self {
Self {
version: header.version,
prev_blockhash: header.prev_blockhash.to_string(),
merkle_root: header.merkle_root.to_string(),
time: header.time,
bits: header.bits,
nonce: header.nonce,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BlockInfo {
pub hash: String,
pub height: u32,
pub header: BlockHeader,
pub tx_count: usize,
pub size: usize,
pub weight: usize,
}