bdkffi::electrum

Struct ElectrumClient

Source
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

Source

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

Source

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, 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( &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, 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.

Source

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

Broadcasts a transaction to the network.

Source

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.

Source

pub fn server_features(&self) -> Result<ServerFeaturesRes, ElectrumError>

Returns the capabilities of the server.

Source

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.

Source

pub fn block_header(&self, height: u64) -> Result<Header, ElectrumError>

Gets the block header for height height.

Source

pub fn block_headers_subscribe( &self, ) -> Result<HeaderNotification, ElectrumError>

Subscribes to notifications for new block headers, by sending a blockchain.headers.subscribe call.

Source

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.

Source

pub fn ping(&self) -> Result<(), ElectrumError>

Pings the server.

Source

pub fn relay_fee(&self) -> Result<f64, ElectrumError>

Returns the minimum accepted fee by the server’s node in Bitcoin, not Satoshi.

Source

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

Source§

impl<UT> LowerError<UT> for ElectrumClient

Source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
Source§

impl<UT> LowerReturn<UT> for ElectrumClient

Source§

type ReturnType = <Arc<ElectrumClient> as LowerReturn<UniFfiTag>>::ReturnType

The type that should be returned by scaffolding functions for this type. Read more
Source§

fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>

Lower the return value from an scaffolding call Read more
§

fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>

Lower the return value for failed argument lifts Read more
Source§

impl<UT> TypeId<UT> for ElectrumClient

Source§

const TYPE_ID_META: MetadataBuffer

Auto Trait Implementations§

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.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
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