pub struct ElectrumClient(/* 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.
Implementations§
Source§impl ElectrumClient
impl ElectrumClient
Sourcepub fn new(url: String, socks5: Option<String>) -> Result<Self, ElectrumError>
pub fn new(url: String, socks5: Option<String>) -> Result<Self, ElectrumError>
Creates a new bdk client from a electrum_client::ElectrumApi Optional: Set the proxy of the builder
Sourcepub fn full_scan(
&self,
request: Arc<FullScanRequest>,
stop_gap: u64,
batch_size: u64,
fetch_prev_txouts: bool,
) -> Result<Arc<Update>, ElectrumError>
pub fn full_scan( &self, request: Arc<FullScanRequest>, stop_gap: u64, batch_size: u64, fetch_prev_txouts: bool, ) -> Result<Arc<Update>, ElectrumError>
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 previousTxOutsfor 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 those TxOuts are not present in the transaction graph.
Sourcepub fn sync(
&self,
request: Arc<SyncRequest>,
batch_size: u64,
fetch_prev_txouts: bool,
) -> Result<Arc<Update>, ElectrumError>
pub fn sync( &self, request: Arc<SyncRequest>, batch_size: u64, fetch_prev_txouts: bool, ) -> Result<Arc<Update>, ElectrumError>
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, seeSyncRequest.batch_size: specifies the max number of script pubkeys to request for in a single batch request.fetch_prev_txouts: specifies whether we want previousTxOutsfor 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 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.
Sourcepub fn transaction_broadcast(
&self,
tx: &Transaction,
) -> Result<Arc<Txid>, ElectrumError>
pub fn transaction_broadcast( &self, tx: &Transaction, ) -> Result<Arc<Txid>, ElectrumError>
Broadcasts a transaction to the network.
Sourcepub fn fetch_tx(
&self,
txid: Arc<Txid>,
) -> Result<Arc<Transaction>, ElectrumError>
pub fn fetch_tx( &self, txid: Arc<Txid>, ) -> Result<Arc<Transaction>, ElectrumError>
Fetch transaction of given Txid.
If it hits the cache it will return the cached version and avoid making the request.
Sourcepub fn server_features(&self) -> Result<ServerFeaturesRes, ElectrumError>
pub fn server_features(&self) -> Result<ServerFeaturesRes, ElectrumError>
Returns the capabilities of the server.
Sourcepub fn estimate_fee(&self, number: u64) -> Result<f64, ElectrumError>
pub fn estimate_fee(&self, number: u64) -> Result<f64, ElectrumError>
Estimates the fee required in bitcoin per kilobyte to confirm a transaction in number blocks.
Sourcepub fn block_header(&self, height: u64) -> Result<Header, ElectrumError>
pub fn block_header(&self, height: u64) -> Result<Header, ElectrumError>
Gets the block header for height height.
Sourcepub fn block_headers_subscribe(
&self,
) -> Result<HeaderNotification, ElectrumError>
pub fn block_headers_subscribe( &self, ) -> Result<HeaderNotification, ElectrumError>
Subscribes to notifications for new block headers, by sending a blockchain.headers.subscribe call.
Sourcepub fn block_headers_pop(
&self,
) -> Result<Option<HeaderNotification>, ElectrumError>
pub fn block_headers_pop( &self, ) -> Result<Option<HeaderNotification>, ElectrumError>
Tries to pop one queued notification for a new block header that we might have received.
Returns None if there are no items in the queue.
Sourcepub fn ping(&self) -> Result<(), ElectrumError>
pub fn ping(&self) -> Result<(), ElectrumError>
Pings the server.
Sourcepub fn relay_fee(&self) -> Result<f64, ElectrumError>
pub fn relay_fee(&self) -> Result<f64, ElectrumError>
Returns the minimum accepted fee by the server’s node in Bitcoin, not Satoshi.
Sourcepub fn transaction_get_raw(
&self,
txid: Arc<Txid>,
) -> Result<Vec<u8>, ElectrumError>
pub fn transaction_get_raw( &self, txid: Arc<Txid>, ) -> Result<Vec<u8>, ElectrumError>
Gets the raw bytes of a transaction with txid. Returns an error if not found.
Trait Implementations§
Source§impl<UT> LiftRef<UT> for ElectrumClient
impl<UT> LiftRef<UT> for ElectrumClient
type LiftType = Arc<ElectrumClient>
Source§impl<UT> LowerError<UT> for ElectrumClient
impl<UT> LowerError<UT> for ElectrumClient
Source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
Source§impl<UT> LowerReturn<UT> for ElectrumClient
impl<UT> LowerReturn<UT> for ElectrumClient
Source§type ReturnType = <Arc<ElectrumClient> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<ElectrumClient> as LowerReturn<UniFfiTag>>::ReturnType
Source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
§fn handle_failed_lift(
error: LiftArgsError,
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>
Source§impl<UT> TypeId<UT> for ElectrumClient
impl<UT> TypeId<UT> for ElectrumClient
const TYPE_ID_META: MetadataBuffer
Auto Trait Implementations§
impl !Freeze for ElectrumClient
impl RefUnwindSafe for ElectrumClient
impl Send for ElectrumClient
impl Sync for ElectrumClient
impl Unpin for ElectrumClient
impl UnwindSafe for ElectrumClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more