Trait Wallet

Source
pub trait Wallet {
    // Required methods
    fn get_new_address(
        &self,
    ) -> impl Future<Output = ClientResult<Address>> + Send;
    fn get_transaction(
        &self,
        txid: &Txid,
    ) -> impl Future<Output = ClientResult<GetTransaction>> + Send;
    fn get_utxos(
        &self,
    ) -> impl Future<Output = ClientResult<Vec<ListUnspent>>> + Send;
    fn list_transactions(
        &self,
        count: Option<usize>,
    ) -> impl Future<Output = ClientResult<Vec<ListTransactions>>> + Send;
    fn list_wallets(
        &self,
    ) -> impl Future<Output = ClientResult<Vec<String>>> + Send;
    fn create_raw_transaction(
        &self,
        raw_tx: CreateRawTransaction,
    ) -> impl Future<Output = ClientResult<Transaction>> + Send;
}
Expand description

Wallet functionality that any Bitcoin client without private keys that interacts with the Bitcoin network should provide.

For signing transactions, see Signer.

§Note

This is a fully async trait. The user should be responsible for handling the async nature of the trait methods. And if implementing this trait for a specific type that is not async, the user should consider wrapping with tokio’s spawn_blocking or any other method.

Required Methods§

Source

fn get_new_address(&self) -> impl Future<Output = ClientResult<Address>> + Send

Generates new address under own control for the underlying Bitcoin client’s wallet.

Source

fn get_transaction( &self, txid: &Txid, ) -> impl Future<Output = ClientResult<GetTransaction>> + Send

Gets information related to a transaction.

§Note

This assumes that the transaction is present in the underlying Bitcoin client’s wallet.

Source

fn get_utxos( &self, ) -> impl Future<Output = ClientResult<Vec<ListUnspent>>> + Send

Gets all Unspent Transaction Outputs (UTXOs) for the underlying Bitcoin client’s wallet.

Source

fn list_transactions( &self, count: Option<usize>, ) -> impl Future<Output = ClientResult<Vec<ListTransactions>>> + Send

Lists transactions in the underlying Bitcoin client’s wallet.

§Parameters
  • count: The number of transactions to list. If None, assumes a maximum of 10 transactions.
Source

fn list_wallets(&self) -> impl Future<Output = ClientResult<Vec<String>>> + Send

Lists all wallets in the underlying Bitcoin client.

Source

fn create_raw_transaction( &self, raw_tx: CreateRawTransaction, ) -> impl Future<Output = ClientResult<Transaction>> + Send

Creates a raw transaction.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§