Wallets in Cardano SL

While addresses discussed in Addresses section are fundamental to send and receive funds, wallets are a way to simplify these processes for end-users.

What is a Wallet?

In Cardano, wallets are defined in the following manner:

data CWallet = CWallet
    { cwAddress :: !CAddress
    , cwAmount  :: !Coin
    , cwMeta    :: !CWalletMeta

where CWalletMeta is a type that presently indicates whether the wallet is shared or personal, the currency that this wallet uses, and the wallet’s name. With this, the wallet type is easily extensible, as any additional features can be added to the CWalletMeta type, leaving the Address and Coin fields untouched. (Every wallet, regardless of name, type and currency, must have the said fields.)

Transactions and Wallets

In the Transactions section, the structure of transactions is defined. However, to facilitate client operations, transactions are represented differently in clients. They are represented as

data CTx = CTx
    { ctId            :: CTxId
    , ctAmount        :: Coin
    , ctConfirmations :: Word
    , ctType          :: CTType -- it includes all "meta data"

Essentially, a client transaction is composed by the actual transaction Id, by the amount the wallet in question received, the number of confirmations this transaction has received (i.e., the number of blocks that are currently on top of the block containing the transaction in question), and a label indicating whether the transaction is incoming or outcoming. Inside the CTType datatype, there is, similarly to CWallet, a datatype with meta-information concerning the transaction. Aside from a label indicating whether it is ingoing or outgoing, this meta-information - the datatype CTxMeta - indicates the transaction’s currency, its title or name, its description and the POSIX-formatted date of sending it.

Wallet Backend API

Currently, the wallet’s API provides a series of methods to work with wallets. The servant Haskell library that provides a modular approach to API-building is used. This library uses combinators both to build atomic HTTP actions and to glue these atomic methods together to form larger and more complete APIs.

If the event requests fail, there is a WalletError type, which is simply a wrapper over Text to show what happened.

Documentation for wallet web API is available here.

Please notice that wallet web API is available only if you run a node with --wallet option. Default port for this API is 8090.