How wallets sync
What a wallet reads from a node, what it verifies, and how it finds and spends notes.
On this page
The loop#
The wallet follows GET /headers and GET /effects in batches (16 blocks by default, 64 at most) and writes its state after each batch. Every request overlaps the wallet's tip by one header; a node that no longer serves that header is reported as a history conflict.
For each block, before anything is applied:
- The header carries the validator's signature over a commitment the wallet recomputes from the header fields. On a multi-validator chain this is a commit certificate.
previousis the wallet's tip, the height is the next one and time moves forward.- The effects belong to that header (height, commitment, transaction count).
- The note root and note count equal what the wallet's own tree gives after appending the served leaves.
- The nullifier digest and count equal the fold of the served nullifiers.
Not checked: proofs are not downloaded and the transaction root is not recomputed.
Finding notes#
- Feed every leaf of every transaction, in order, into a witness set; track the leaves that belong to you. After the last leaf of a block, the set's root equals that block's note root.
- Try to open each envelope: slots 0 and 1 of each proof, and slot 2 of a pool trade.
- Credit a note only if the plaintext parses strictly, the amount is between 1 and 2^63 - 1, the asset is non-zero, the owner is yours and the commitment recomputed from asset, amount, owner and salt equals the leaf under the signed root. Anything else is counted as rejected.
- A wrong envelope can hide a note from the wallet. It cannot make the wallet credit one.
Spending and detecting spends#
- Compute the nullifier of each note you own and look for it in later blocks; it marks the note spent.
- Build a transaction against a root that stays acceptable for the node's root window. Choose an expiry no later than the anchor height plus the maximum intent lifetime.
- Use a fresh salt for every note and every pool-trade binding.
Pool output#
After a pool trade the third leaf is the note the ledger created for the recipient binding you chose. Slot 2 holds the opening of that binding. The wallet takes the asset and amount from the public tape as a candidate and credits the note only if the commitment recomputes.
Second node#
With a second node configured, the wallet compares the header at its height after every sync. A different commitment stops the wallet; an unreachable second node does too, unless configured as best effort.
Submitting and outcomes#
Submit { proofs, journals, envelopes[, launch] } to POST /transactions. An HTTP answer is only "submitted". The wallet reports "included" after it finds its own commitments and nullifiers in a block it verified. After a lost answer it keeps inputs reserved and never resubmits.
Known gaps in the wallet design#
- The wallet keeps no full nullifier or commitment set, so it cannot tell beforehand that a counterparty's half spends a spent note; the ledger refuses it.
- The state file is rewritten in full on every change.
- Network privacy is not addressed: the node sees the wallet's address and request timing.
- The market state is fetched whole in one response, capped at 4 MiB.