1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Dust sub-wallet — port of `@midnight-ntwrk/wallet-sdk-dust-wallet`.
//!
//! Midnight's transaction fees are paid in **DUST**, a per-NIGHT-UTXO
//! resource that accrues from the moment a NIGHT UTXO is registered for
//! dust generation. Without dust there is no way to pay a non-claim-rewards
//! transaction's fee, so this module is the missing piece between the
//! unshielded sub-wallet and a transaction that actually lands in-block.
//!
//! ## Module layout
//!
//! - [`state`] — `DustState`, the wallet's local view: wraps the ledger's
//! [`moonproof_ledger::ledger::dust::DustLocalState`] with our public-key /
//! pending-spends / sync-progress bookkeeping.
//! - [`balances`] — read-only projections over `DustState`: balance,
//! available coins, generation info, "what would dust look like if I
//! registered these NIGHTs?" estimation.
//! - [`transacting`] — pure-logic recipe builders for register /
//! deregister / fee-balancing transactions. No I/O, no clocks.
//! - [`ledger_adapter`] — thin translation layer that turns a recipe into
//! a `moonproof_ledger::ledger::Intent` / `Transaction`. Owns the
//! `Db = InMemoryDB` choice and the prove/seal/serialize pipeline.
//!
//! ## Where dust shows up in tx submission
//!
//! 1. **Genesis**: a fresh wallet has NIGHT UTXOs but no dust. The first
//! transaction is an *address-only* registration — `dust_actions =
//! Some(DustActions { spends: [], registrations: [reg] })` where
//! `reg.dust_address = Some(dust_pk)`. After this lands, the chain
//! auto-delegates dust generation for subsequent NIGHT receipts.
//! 2. **Per-UTXO registration**: existing NIGHT UTXOs created *before*
//! address delegation don't auto-generate dust. The wallet registers
//! them by spending and re-receiving them inside an unshielded offer
//! that carries the dust registration in the same intent.
//! 3. **Fee balancing**: every non-`ClaimRewards` transaction needs a
//! dust input that covers `Transaction::fees_with_margin(...)`. The
//! [`transacting::compute_fee_balancing_recipe`] helper iteratively
//! converges on the minimum dust spend that covers the new tx's fee
//! (the addition of dust spends increases the fee, so we re-estimate
//! until the picked set covers the new estimate).
pub use ;
pub use ;
pub use DustTreeRoots;
pub use ;
pub use ;
pub use ;