Trait bdk::blockchain::Blockchain[][src]

pub trait Blockchain {
    fn get_capabilities(&self) -> HashSet<Capability>;
fn setup<D: BatchDatabase, P: 'static + Progress>(
        &self,
        stop_gap: Option<usize>,
        database: &mut D,
        progress_update: P
    ) -> Result<(), Error>;
fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Error>;
fn broadcast(&self, tx: &Transaction) -> Result<(), Error>;
fn get_height(&self) -> Result<u32, Error>;
fn estimate_fee(&self, target: usize) -> Result<FeeRate, Error>; fn sync<D: BatchDatabase, P: 'static + Progress>(
        &self,
        stop_gap: Option<usize>,
        database: &mut D,
        progress_update: P
    ) -> Result<(), Error> { ... } }

Trait that defines the actions that must be supported by a blockchain backend

Required methods

fn get_capabilities(&self) -> HashSet<Capability>[src]

Return the set of Capability supported by this backend

fn setup<D: BatchDatabase, P: 'static + Progress>(
    &self,
    stop_gap: Option<usize>,
    database: &mut D,
    progress_update: P
) -> Result<(), Error>
[src]

Setup the backend and populate the internal database for the first time

This method is the equivalent of Blockchain::sync, but it's guaranteed to only be called once, at the first Wallet::sync.

The rationale behind the distinction between sync and setup is that some custom backends might need to perform specific actions only the first time they are synced.

For types that do not have that distinction, only this method can be implemented, since Blockchain::sync defaults to calling this internally if not overridden.

fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Error>[src]

Fetch a transaction from the blockchain given its txid

fn broadcast(&self, tx: &Transaction) -> Result<(), Error>[src]

Broadcast a transaction

fn get_height(&self) -> Result<u32, Error>[src]

Return the current height

fn estimate_fee(&self, target: usize) -> Result<FeeRate, Error>[src]

Estimate the fee rate required to confirm a transaction in a given target of blocks

Loading content...

Provided methods

fn sync<D: BatchDatabase, P: 'static + Progress>(
    &self,
    stop_gap: Option<usize>,
    database: &mut D,
    progress_update: P
) -> Result<(), Error>
[src]

Populate the internal database with transactions and UTXOs

If not overridden, it defaults to calling Blockchain::setup internally.

This method should implement the logic required to iterate over the list of the wallet's script_pubkeys using Database::iter_script_pubkeys and look for relevant transactions in the blockchain to populate the database with BatchOperations::set_tx and BatchOperations::set_utxo.

This method should also take care of removing UTXOs that are seen as spent in the blockchain, using BatchOperations::del_utxo.

The progress_update object can be used to give the caller updates about the progress by using Progress::update.

Loading content...

Implementations on Foreign Types

impl<T: Blockchain> Blockchain for Arc<T>[src]

Loading content...

Implementors

impl Blockchain for AnyBlockchain[src]

impl Blockchain for CompactFiltersBlockchain[src]

This is supported on crate feature compact_filters only.

impl Blockchain for ElectrumBlockchain[src]

This is supported on crate feature electrum only.

impl Blockchain for EsploraBlockchain[src]

This is supported on crate feature esplora only.
Loading content...