use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OtsProof {
pub hash: [u8; 32],
pub bitcoin_height: u32,
pub merkle_branch: Vec<[u8; 32]>,
pub merkle_root: [u8; 32],
#[serde(default)]
pub calendar_server: Option<String>,
}
impl OtsProof {
pub fn new(hash: [u8; 32], bitcoin_height: u32) -> Self {
Self {
hash,
bitcoin_height,
merkle_branch: Vec::new(),
merkle_root: [0u8; 32],
calendar_server: None,
}
}
}
#[derive(Debug, Clone)]
pub struct OtsVerification {
pub valid: bool,
pub bitcoin_height: u32,
pub block_timestamp: Option<u64>,
}
#[derive(Debug, thiserror::Error)]
pub enum OtsError {
#[error("calendar server unreachable: {0}")]
CalendarUnreachable(String),
#[error("proof invalid: {0}")]
InvalidProof(String),
#[error("Bitcoin backend unavailable: {0}")]
BitcoinBackend(String),
}