pub trait CryptoWallet: Sized + Clone {
    type ErrorType: Error + Send + Sync + 'static;
    type CryptoAmount: CryptoAmount;
    type BlockchainClient: BlockchainConnector;
    type NetworkType;
    type WalletBuilder: CryptoWalletBuilder<Self>;
    type AddressFormat;

    // Required methods
    fn set_blockchain_client(&mut self, client: Self::BlockchainClient);
    fn blockchain_client(
        &self
    ) -> Result<&Self::BlockchainClient, Self::ErrorType>;
    fn balance<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<Self::CryptoAmount, Self::ErrorType>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn transfer<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        send_amount: &'life1 Self::CryptoAmount,
        public_address: &'life2 str
    ) -> Pin<Box<dyn Future<Output = Result<String, Self::ErrorType>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn sync<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::ErrorType>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn receive_address(&self) -> Result<String, Self::ErrorType>;
    fn builder() -> Self::WalletBuilder;
}
Expand description

Provides common functionality for a crypto wallet. Contains functions to get the balance, send and receive transactions, and sync the wallet with the blockchain.

Required Associated Types§

source

type ErrorType: Error + Send + Sync + 'static

ErrorType is the type of error that is returned by the CryptoWallet

source

type CryptoAmount: CryptoAmount

CryptoAmount is the type of amount that is used by the CryptoWallet to represent amounts of cryptocurrency

source

type BlockchainClient: BlockchainConnector

BlockchainClient is the type of BlockchainConnector that is used by the CryptoWallet to connect to the blockchain

source

type NetworkType

NetworkType is the type of network that the CryptoWallet is connected to

source

type WalletBuilder: CryptoWalletBuilder<Self>

WalletBuilder is the type of builder that is used to build a CryptoWallet

source

type AddressFormat

AddressFormat is the type of address format that is used by the CryptoWallet

Required Methods§

source

fn set_blockchain_client(&mut self, client: Self::BlockchainClient)

Associates a particular blockchain client with the CryptoWallet

source

fn blockchain_client(&self) -> Result<&Self::BlockchainClient, Self::ErrorType>

Returns the blockchain client that is associated with the CryptoWallet if it exists, otherwise returns an error

source

fn balance<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Self::CryptoAmount, Self::ErrorType>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Returns the balance of the CryptoWallet as a CryptoAmount

source

fn transfer<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, send_amount: &'life1 Self::CryptoAmount, public_address: &'life2 str ) -> Pin<Box<dyn Future<Output = Result<String, Self::ErrorType>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Sends a transaction from the CryptoWallet to a given public address with a given amount

source

fn sync<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<(), Self::ErrorType>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Syncs the CryptoWallet with the blockchain

source

fn receive_address(&self) -> Result<String, Self::ErrorType>

Returns the receive address of the CryptoWallet, this is the address that is used to receive transactions

source

fn builder() -> Self::WalletBuilder

Returns a builder for the CryptoWallet that can be used to build a CryptoWallet with custom options

Implementors§