use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{BlockHash, Height, Timestamp};
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct TxStatus {
#[schemars(example = true)]
pub confirmed: bool,
#[schemars(example = Some(916656))]
pub block_height: Option<Height>,
#[schemars(example = Some("000000000000000000012711f7e0d13e586752a42c66e25faf75f159b3d04911".to_string()))]
pub block_hash: Option<BlockHash>,
#[schemars(example = Some(1759000868))]
pub block_time: Option<Timestamp>,
}
impl TxStatus {
pub const UNCONFIRMED: Self = Self {
confirmed: false,
block_hash: None,
block_height: None,
block_time: None,
};
pub fn confirmed(height: Height, block_hash: BlockHash, block_time: Timestamp) -> Self {
Self {
confirmed: true,
block_height: Some(height),
block_hash: Some(block_hash),
block_time: Some(block_time),
}
}
}