2023-03-10 13:40:27 +13:00
|
|
|
#![doc = include_str!("../README.md")]
|
2023-11-12 21:31:44 +08:00
|
|
|
use bdk_chain::{BlockId, ConfirmationTimeHeightAnchor};
|
2023-03-09 10:59:18 +13:00
|
|
|
use esplora_client::TxStatus;
|
2023-03-02 16:23:06 +11:00
|
|
|
|
|
|
|
pub use esplora_client;
|
2023-03-07 17:04:06 +03:00
|
|
|
|
|
|
|
#[cfg(feature = "blocking")]
|
2023-03-09 10:59:18 +13:00
|
|
|
mod blocking_ext;
|
2023-03-03 12:07:04 +01:00
|
|
|
#[cfg(feature = "blocking")]
|
2023-03-09 10:59:18 +13:00
|
|
|
pub use blocking_ext::*;
|
2023-03-02 16:23:06 +11:00
|
|
|
|
2023-03-09 10:59:18 +13:00
|
|
|
#[cfg(feature = "async")]
|
|
|
|
mod async_ext;
|
|
|
|
#[cfg(feature = "async")]
|
|
|
|
pub use async_ext::*;
|
2023-03-02 16:23:06 +11:00
|
|
|
|
2023-07-19 17:42:52 +08:00
|
|
|
const ASSUME_FINAL_DEPTH: u32 = 15;
|
|
|
|
|
2023-11-12 21:31:44 +08:00
|
|
|
fn anchor_from_status(status: &TxStatus) -> Option<ConfirmationTimeHeightAnchor> {
|
2023-07-19 17:42:52 +08:00
|
|
|
if let TxStatus {
|
|
|
|
block_height: Some(height),
|
|
|
|
block_hash: Some(hash),
|
|
|
|
block_time: Some(time),
|
|
|
|
..
|
|
|
|
} = status.clone()
|
|
|
|
{
|
2023-11-12 21:31:44 +08:00
|
|
|
Some(ConfirmationTimeHeightAnchor {
|
2023-07-19 17:42:52 +08:00
|
|
|
anchor_block: BlockId { height, hash },
|
|
|
|
confirmation_height: height,
|
|
|
|
confirmation_time: time,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
None
|
2023-05-18 14:04:48 +08:00
|
|
|
}
|
|
|
|
}
|