Skip to content

Architecture

The Wallet class is a system of cooperating components. Knowing some of the underlying mechanics is useful for development.

This is a very brief, high-level overview.

The pieces

flowchart TD
    Wallet["<b>Wallet</b><br/>lifecycle, file storage, accounts"]
    RpcClient["<b>RpcClient</b>"]
    UtxoProcessor["<b>UtxoProcessor</b>"]
    Ctx0["<b>UtxoContext</b><br/>account 0"]
    Ctx1["<b>UtxoContext</b><br/>account 1"]

    Wallet -- owns --> RpcClient
    Wallet -- owns --> UtxoProcessor
    RpcClient -- pushes notifications --> UtxoProcessor
    UtxoProcessor -- routes per-account --> Ctx0
    UtxoProcessor -- routes per-account --> Ctx1
Component Job
Wallet Lifecycle, on-disk file storage, account list, event multiplexer. The object your code interacts with.
RpcClient The wRPC connection. Used internally for calls and as the source of node-pushed notifications.
UtxoProcessor Subscribes to virtual-chain / UTXO notifications, tracks synced state, routes UTXO changes to the right UtxoContext.
UtxoContext One per activated account. Holds tracked addresses, per-state balance (mature, pending, outgoing), and the mature UTXO set the coin selector pulls from.

The wallet does not poll the node for UTXO state. It is fed by the processor from notifications — see Sync State for what gates that flow.

Where to next