This crate provides WalletClient
trait which is responsible for interacting with transaction index and provide
following functionalities on per-wallet basis:
- Wallet creation
- Address generation
- Balance tracking
- Transaction history
- Transaction creation and signing (with automatic unspent transaction selection)
Below is a high level design diagram of this crate:
This trait declares APIs for accessing various functionalities for a wallet:
- Wallet creation and retrieval:
new_wallet()
andwallets()
functions. - Address generation and retrieval:
new_address()
andaddresses()
functions. - Balance tracking:
balance()
function. - Transaction history:
history()
function. - Transaction creation and signing:
create_and_broadcast_transaction()
function. This function also handles automatic unspent transaction selection.
Besides above functions, WalletClient
also exposes sync()
and sync_all()
functions which are used to synchronize
transaction index with Thaler Experimental Network. This synchronization mechanism is subject to change. Currently, a default
implementation (DefaultWalletClient
) of WalletClient
is provided.
WalletClient
exposes a public interface for interacting with a wallet. In order to provide these capabilities,
DefaultWallet
delegates storage of each type of entity to its own Service. Currently, there are
following services:
KeyService
exposes key related operations (generate
and get_keys
) on top of any Storage
implementation.
generate
: Generates a new private key for givenwallet_id
and encrypts it with givenpassphrase
before storing.get_keys
: Returns all the keys stored for givenwallet_id
and decrypts them with givenpassphrase
.
WalletService
exposes wallet related operations (create
and get
) on top of any Storage
implementation.
create
: Creates a new wallet and returnswallet_id
. This function also encrypts all the data usingpassphrase
before storing it inStorage
.get
: Retrieves awallet_id
fromStorage
and decrypts it with givenpassphrase
.
To see this crate's API docs. Run following command from chain
directory.
cargo doc --package client-core --no-deps --open