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: EThe internal [electrum_client::ElectrumApi]
Implementations§
Source§impl<E: ElectrumApi> BdkElectrumClient<E>
impl<E: ElectrumApi> BdkElectrumClient<E>
Sourcepub fn populate_tx_cache(
&self,
txs: impl IntoIterator<Item = impl Into<Arc<Transaction>>>,
)
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.
Sourcepub fn fetch_tx(&self, txid: Txid) -> Result<Arc<Transaction>, Error>
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.
Sourcepub fn transaction_broadcast(&self, tx: &Transaction) -> Result<Txid, Error>
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].
Sourcepub 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>
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, seeFullScanRequest.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 previousTxOuts 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 likeWallet.calculate_feeandWallet.calculate_fee_ratewill return aCalculateFeeError::MissingTxOuterror if thoseTxOuts are not present in the transaction graph.
Sourcepub fn sync<I: 'static>(
&self,
request: impl Into<SyncRequest<I>>,
batch_size: usize,
fetch_prev_txouts: bool,
) -> Result<SyncResponse, Error>
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, seeSyncRequestbatch_size: specifies the max number of script pubkeys to request for in a single batch requestfetch_prev_txouts: specifies whether we want previousTxOuts 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 likeWallet.calculate_feeandWallet.calculate_fee_ratewill return aCalculateFeeError::MissingTxOuterror if thoseTxOuts 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.