Expand description
Re-export the entire miden_client crate so external projects can use a single dependency.
PSWAP chain tracking — follows partial-swap orders across fills so the
creator can always see the current tip and reclaim the unfilled balance.
Flow:
- Create → persist a
PswapLineageRecord+ asset-pair tag subscription. - Sync →
PswapChainObservercollects PSWAP-attachment notes;discovery::discover_pswap_roundscorrelates them with tracked-note consumption events and emits onePswapLineageRoundUpdateper round. - Reclaim →
Client::build_pswap_cancel_by_order.
Protocol invariants (≤1 payback + ≤1 remainder per round, attachment
word layout, deterministic reconstruction) live on
miden_standards::note::PswapNote.
§Trust model
Observed notes are matched to an order by the order_id on their attachment, which the sender
controls — so the (order_id, depth) bucket is untrusted. Anyone who knows one of our live
order ids (public orders expose it on-chain) can publish a note carrying that id and our tag. We
never trust such a note on its face: for each candidate we reconstruct the note it should be
from our stored depth-0 note (payback_note / remainder_note) and accept it only if the
reconstructed id matches the observed id. A forger can’t produce a matching id without actually
emitting a genuine payback/remainder of our order (which pays our creator), so this is an
authenticity check, not a checksum. Candidates that fail are skipped — they can’t advance the
tip, change a round’s classification, or be inserted as consumable notes. Classification runs
only on the surviving genuine notes, never on the raw observed count.
Structs§
- Pswap
Chain Observer - Per-sync collector of PSWAP-attachment notes seen this sync.
- Pswap
Lineage Record - Persistent record of one PSWAP order’s chain state. The order id and creator
are mirrored here so the common read paths — keying, filtering — stay
lookup-free. Only the remaining amounts are stored; the asset pair’s faucets,
the script/recipient, and the
note_typeall live on the depth-0 note, fetched on demand fromoutput_notesbyoriginal_note_id(seestore::get_original_pswap) when reconstruction, a depth-0 reclaim, or asset-pair-tag derivation needs them. - Pswap
Transaction Observer - Registers a
PswapLineageRecord+ asset-pair tag subscription for every depth-0 PSWAP this wallet emits. Creator-agnostic (service wallets are tracked too; reclaim surfacesCreatorNotLocallater).
Enums§
- Pswap
Lineage Error - Failures raised by the PSWAP chain-tracking subsystem.
- Pswap
Lineage State - Lifecycle state of a PSWAP order. Discriminants are part of the serialized encoding — do not renumber.