Trait walletd_coin_core::CryptoWallet
source · 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§
sourcetype ErrorType: Error + Send + Sync + 'static
type ErrorType: Error + Send + Sync + 'static
ErrorType is the type of error that is returned by the CryptoWallet
sourcetype CryptoAmount: CryptoAmount
type CryptoAmount: CryptoAmount
CryptoAmount is the type of amount that is used by the CryptoWallet to represent amounts of cryptocurrency
sourcetype BlockchainClient: BlockchainConnector
type BlockchainClient: BlockchainConnector
BlockchainClient is the type of BlockchainConnector that is used by the CryptoWallet to connect to the blockchain
sourcetype NetworkType
type NetworkType
NetworkType is the type of network that the CryptoWallet is connected to
sourcetype WalletBuilder: CryptoWalletBuilder<Self>
type WalletBuilder: CryptoWalletBuilder<Self>
WalletBuilder is the type of builder that is used to build a CryptoWallet
sourcetype AddressFormat
type AddressFormat
AddressFormat is the type of address format that is used by the CryptoWallet
Required Methods§
sourcefn set_blockchain_client(&mut self, client: Self::BlockchainClient)
fn set_blockchain_client(&mut self, client: Self::BlockchainClient)
Associates a particular blockchain client with the CryptoWallet
sourcefn blockchain_client(&self) -> Result<&Self::BlockchainClient, Self::ErrorType>
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
sourcefn 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 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
sourcefn 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 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
sourcefn 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 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
sourcefn receive_address(&self) -> Result<String, Self::ErrorType>
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
sourcefn builder() -> Self::WalletBuilder
fn builder() -> Self::WalletBuilder
Returns a builder for the CryptoWallet that can be used to build a CryptoWallet with custom options