Struct BdkElectrumClient

Source
pub struct BdkElectrumClient<E> {
    pub inner: E,
    /* private fields */
}
Expand description

Wrapper around an [electrum_client::ElectrumApi] which includes an internal in-memory transaction cache to avoid re-fetching already downloaded transactions.

Fields§

§inner: E

The internal [electrum_client::ElectrumApi]

Implementations§

Source§

impl<E: ElectrumApi> BdkElectrumClient<E>

Source

pub fn new(client: E) -> Self

Creates a new bdk client from a [electrum_client::ElectrumApi]

Source

pub fn populate_tx_cache( &self, txs: impl IntoIterator<Item = impl Into<Arc<Transaction>>>, )

Inserts transactions into the transaction cache so that the client will not fetch these transactions.

Source

pub fn fetch_tx(&self, txid: Txid) -> Result<Arc<Transaction>, Error>

Fetch transaction of given txid.

If it hits the cache it will return the cached version and avoid making the request.

Source

pub fn transaction_broadcast(&self, tx: &Transaction) -> Result<Txid, Error>

Broadcasts a transaction to the network.

This is a re-export of [ElectrumApi::transaction_broadcast].

Source

pub fn full_scan<K: Ord + Clone>( &self, request: impl Into<FullScanRequest<K>>, stop_gap: usize, batch_size: usize, fetch_prev_txouts: bool, ) -> Result<FullScanResponse<K>, Error>

Full scan the keychain scripts specified with the blockchain (via an Electrum client) and returns updates for bdk_chain data structures.

  • request: struct with data required to perform a spk-based blockchain client full scan, see FullScanRequest.
  • stop_gap: the full scan for each keychain stops after a gap of script pubkeys with no associated transactions.
  • batch_size: specifies the max number of script pubkeys to request for in a single batch request.
  • fetch_prev_txouts: specifies whether we want previous TxOuts for fee calculation. Note that this requires additional calls to the Electrum server, but is necessary for calculating the fee on a transaction if your wallet does not own the inputs. Methods like Wallet.calculate_fee and Wallet.calculate_fee_rate will return a CalculateFeeError::MissingTxOut error if those TxOuts are not present in the transaction graph.
Source

pub fn sync<I: 'static>( &self, request: impl Into<SyncRequest<I>>, batch_size: usize, fetch_prev_txouts: bool, ) -> Result<SyncResponse, Error>

Sync a set of scripts with the blockchain (via an Electrum client) for the data specified and returns updates for bdk_chain data structures.

  • request: struct with data required to perform a spk-based blockchain client sync, see SyncRequest
  • batch_size: specifies the max number of script pubkeys to request for in a single batch request
  • fetch_prev_txouts: specifies whether we want previous TxOuts for fee calculation. Note that this requires additional calls to the Electrum server, but is necessary for calculating the fee on a transaction if your wallet does not own the inputs. Methods like Wallet.calculate_fee and Wallet.calculate_fee_rate will return a CalculateFeeError::MissingTxOut error if those TxOuts are not present in the transaction graph.

If the scripts to sync are unknown, such as when restoring or importing a keychain that may include scripts that have been used, use full_scan with the keychain.

Trait Implementations§

Source§

impl<E: Debug> Debug for BdkElectrumClient<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<E> !Freeze for BdkElectrumClient<E>

§

impl<E> RefUnwindSafe for BdkElectrumClient<E>
where E: RefUnwindSafe,

§

impl<E> Send for BdkElectrumClient<E>
where E: Send,

§

impl<E> Sync for BdkElectrumClient<E>
where E: Sync,

§

impl<E> Unpin for BdkElectrumClient<E>
where E: Unpin,

§

impl<E> UnwindSafe for BdkElectrumClient<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V