diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index 2b3828952..52d296b34 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -29,6 +29,29 @@ pub trait EsploraAsyncExt { /// `stop_gap` script pubkeys with no associated transactions. `parallel_requests` specifies /// the maximum number of HTTP requests to make in parallel. /// + /// # Example + /// + /// ```no_run + /// use bdk_core::bitcoin::{constants, Network}; + /// use bdk_core::spk_client::FullScanRequest; + /// use bdk_core::CheckPoint; + /// use bdk_esplora::{esplora_client, EsploraAsyncExt}; + /// + /// # async fn example() -> Result<(), bdk_esplora::Error> { + /// let client = esplora_client::Builder::new("https://blockstream.info/api").build_async()?; + /// + /// let request = FullScanRequest::<&str>::builder() + /// .chain_tip(CheckPoint::new( + /// 0, + /// constants::genesis_block(Network::Bitcoin).block_hash(), + /// )) + /// .build(); + /// + /// let response = client.full_scan(request, 10, 5).await?; + /// # Ok(()) + /// # } + /// ``` + /// /// Refer to [crate-level docs](crate) for more. async fn full_scan> + Send>( &self, @@ -43,6 +66,25 @@ pub trait EsploraAsyncExt { /// [`SyncRequest`]). `parallel_requests` specifies the maximum number of HTTP requests to make /// in parallel. /// + /// # Example + /// + /// ```no_run + /// use bdk_core::bitcoin::ScriptBuf; + /// use bdk_core::spk_client::SyncRequest; + /// use bdk_esplora::{esplora_client, EsploraAsyncExt}; + /// + /// # async fn example() -> Result<(), bdk_esplora::Error> { + /// let client = esplora_client::Builder::new("https://blockstream.info/api").build_async()?; + /// + /// let request = SyncRequest::builder() + /// .spks([ScriptBuf::new_op_return(&[0x00; 20])]) + /// .build(); + /// + /// let response = client.sync(request, 5).await?; + /// # Ok(()) + /// # } + /// ``` + /// /// Refer to [crate-level docs](crate) for more. async fn sync> + Send>( &self, diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 225b574ea..190cab895 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -26,6 +26,27 @@ pub trait EsploraExt { /// `stop_gap` script pubkeys with no associated transactions. `parallel_requests` specifies /// the maximum number of HTTP requests to make in parallel. /// + /// # Example + /// + /// ```no_run + /// use bdk_core::bitcoin::{constants, Network}; + /// use bdk_core::spk_client::FullScanRequest; + /// use bdk_core::CheckPoint; + /// use bdk_esplora::{esplora_client, EsploraExt}; + /// + /// let client = esplora_client::Builder::new("https://blockstream.info/api").build_blocking(); + /// + /// let request = FullScanRequest::<&str>::builder() + /// .chain_tip(CheckPoint::new( + /// 0, + /// constants::genesis_block(Network::Bitcoin).block_hash(), + /// )) + /// .build(); + /// + /// let response = client.full_scan(request, 10, 5)?; + /// # Ok::<_, bdk_esplora::Error>(()) + /// ``` + /// /// Refer to [crate-level docs](crate) for more. fn full_scan>>( &self, @@ -40,6 +61,23 @@ pub trait EsploraExt { /// [`SyncRequest`]). `parallel_requests` specifies the maximum number of HTTP requests to make /// in parallel. /// + /// # Example + /// + /// ```no_run + /// use bdk_core::bitcoin::ScriptBuf; + /// use bdk_core::spk_client::SyncRequest; + /// use bdk_esplora::{esplora_client, EsploraExt}; + /// + /// let client = esplora_client::Builder::new("https://blockstream.info/api").build_blocking(); + /// + /// let request = SyncRequest::builder() + /// .spks([ScriptBuf::new_op_return(&[0x00; 20])]) + /// .build(); + /// + /// let response = client.sync(request, 5)?; + /// # Ok::<_, bdk_esplora::Error>(()) + /// ``` + /// /// Refer to [crate-level docs](crate) for more. fn sync>>( &self,