Expand description
Core data model for the accounting plane (plan §2.0).
Everything here is no_std-friendly in spirit (no I/O, no clock, no tokio) so
the whole crate builds for wasm32-unknown-unknown. Amounts are u128 minor
units; no floats anywhere (INV grep-gate: f32|f64 forbidden outside
benches).
Structs§
- Account
- TigerBeetle-compatible account state (plan §2.0). The four counters are
u128minor units.*_postedonly ever grow;*_pendingrise on reserve and fall on post/void/expire. Balances are differences of counters, never stored. - Account
Flags - TigerBeetle-compatible account flags.
- Account
Id - 128-bit account identity. Deterministic function of the canonical tuple, so
any party that knows
(ledger_id, owner, unit, purpose)can derive it with no allocation-time coordination, and it is TigerBeetle-compatible (TB account ids areu128). - Account
Spec - Everything needed to open (or idempotently re-open) an account.
- Balance
View - Read-only balance projection returned by
crate::LedgerBackend::balance. - Cid
- Opaque content identifier for a UCAN allocation grant. Kept as raw bytes so
this crate carries no
hyprstream-pdsdependency (D3 crate boundary): the ledger only correlates a spend to its grant, it never parses the CID. - Did
- A decentralized identifier, carried opaquely (
did:web/did:key/did:at9p). The ledger crate treats DIDs as pseudonymous strings and never resolves or interprets them — per the #924 P0 constraint, no legal-identity fields live in this model; a DID is the only principal handle. - Issue
Transfer - Single-phase issuance (INV-1): the only entry point that grows a unit’s
supply. The debit side MUST be the issuer’s
IssuerLiabilityaccount for the unit; the credit side is the destination. - Outcome
- The recorded result of an operation. Stored under the op’s
TransferId; a replay returns this verbatim (PLAN DECISION 3 — original result, including original errors). - Pending
Reservation - A tracked phase-1 reservation. Held in
CF(pending)in RocksLedger; aBTreeMapentry in MemLedger. - Transfer
- A value movement between two accounts of the same unit (INV-1(b): one
unitfield, never two — cross-issuer movement is two linked transfers). - Transfer
Id - Client-supplied 128-bit transfer id (plan §2c). The id IS the idempotency key: replaying it returns the original outcome (including original errors).
- UnitId
- A resource unit. INV-1(a): the unit names its issuer. Two units with different issuers are different units, full stop — there is no bearer-token representation of value that omits the issuer.
Enums§
- Pending
State - The lifecycle state of a two-phase reservation (plan §2b).
- Purpose
- What an account is for. The purpose participates in the account id, so two accounts of the same owner/unit but different purpose are distinct rows.
- Transfer
Result - What a successful op did — the positive half of an
Outcome.