LocalState
For the complete documentation index, see llms.txt
@midnight/zswap / LocalState
Class: LocalState
The local state of a user/wallet, consisting of a set of unspent coins
It also keeps track of coins that are in-flight, either expecting to spend or expecting to receive, and a local copy of the global coin commitment Merkle tree to generate proofs against.
Constructors
new LocalState()
new LocalState(): LocalState
Creates a new, empty state
Returns
Properties
coins
readonly coins: Set<QualifiedCoinInfo>;
The set of spendable coins of this wallet
firstFree
readonly firstFree: bigint;
The first free index in the internal coin commitments Merkle tree. This may be used to identify which merkle tree updates are necessary.
pendingOutputs
readonly pendingOutputs: Map<string, CoinInfo>;
The outputs that this wallet is expecting to receive in the future
pendingSpends
readonly pendingSpends: Map<string, QualifiedCoinInfo>;
The spends that this wallet is expecting to be finalized on-chain in the future
Methods
apply()
apply(secretKeys, offer): LocalState
Locally applies an offer to the current state, returning the updated state