2023-03-02 16:23:06 +11:00
|
|
|
//! This crate is used for updating structures of [`bdk_chain`] with data from an esplora server.
|
|
|
|
//!
|
|
|
|
//! The star of the show is the [`EsploraExt::scan`] method which scans for relevant
|
2023-03-09 10:59:18 +13:00
|
|
|
//! blockchain data (via esplora) and outputs a [`KeychainScan`](bdk_chain::keychain::KeychainScan).
|
2023-03-02 16:23:06 +11:00
|
|
|
|
2023-03-09 10:59:18 +13:00
|
|
|
use bdk_chain::ConfirmationTime;
|
|
|
|
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-03-09 10:59:18 +13:00
|
|
|
pub(crate) fn map_confirmation_time(
|
|
|
|
tx_status: &TxStatus,
|
|
|
|
height_at_start: u32,
|
|
|
|
) -> ConfirmationTime {
|
2023-03-02 16:23:06 +11:00
|
|
|
match (tx_status.block_time, tx_status.block_height) {
|
|
|
|
(Some(time), Some(height)) if height <= height_at_start => {
|
|
|
|
ConfirmationTime::Confirmed { height, time }
|
|
|
|
}
|
|
|
|
_ => ConfirmationTime::Unconfirmed,
|
|
|
|
}
|
|
|
|
}
|