core.node.services / WalletService

# WalletService

`interface WalletService`

A WalletService is responsible for securely and safely persisting the current state of a wallet to storage. The wallet service vends immutable snapshots of the current wallet for working with: if you build a transaction based on a wallet that isnt current, be aware that it may end up being invalid if the states that were used have been consumed by someone else first

### Properties

cashBalances | `abstract val cashBalances: Map<Currency, Amount>` Returns a snapshot of how much cash we have in each currency, ignoring details like issuer. Note: currencies for which we have no cash evaluate to null, not 0.
currentWallet | `abstract val currentWallet: Wallet` Returns a read-only snapshot of the wallet at the time the call is made. Note that if you consume states or keys in this wallet, you must inform the wallet service so it can update its internal state.

### Functions

notify | `open fun notify(tx: WireTransaction): Wallet` Same as notifyAll but with a single transaction.
notifyAll | `abstract fun notifyAll(txns: Iterable<WireTransaction>): Wallet` Possibly update the wallet by marking as spent states that these transactions consume, and adding any relevant new states that they create. You should only insert transactions that have been successfully verified here

### Inheritors

NodeWalletService | `class NodeWalletService : WalletService` This class implements a simple, in memory wallet that tracks states that are owned by us, and also has a convenience method to auto-generate some self-issued cash states that can be used for test trading. A real wallet would persist states relevant to us into a database and once such a wallet is implemented, this scaffolding can be removed.