moonproof-wallet 0.2.2

Native Rust wallet for the Midnight blockchain — HD derivation, coin balancing, Zswap/unshielded/dust transacting
Documentation
//! Shielded (Zswap) wallet sub-surface.
//!
//! Port of `@midnight-ntwrk/wallet-sdk-shielded-wallet` v1. The shielded
//! wallet tracks **coin commitments** inside a Merkle tree, plus the
//! **nullifiers** we've used to spend our coins. Every output we own is
//! encrypted (`CoinCiphertext`) to our encryption public key; the chain
//! never sees the coin's value or token type in the clear.
//!
//! ## Module layout
//!
//! - [`state`] — `ShieldedState`, wraps `moonproof_ledger::zswap::local::State`
//!   with wallet-side bookkeeping (network id, sync progress).
//! - [`balances`] — read-only projections: available / pending coins, and
//!   wallet-balance sums by
//!   [`moonproof_ledger::coin_structure::coin::ShieldedTokenType`].
//! - [`transacting`] — pure-logic recipe builder. Mirrors TS
//!   `Transacting.ts::makeTransfer`. Uses the shared balancer with a
//!   zero-overhead shielded cost model — shielded inputs pay for
//!   themselves via the zswap binding commitment, not via an explicit
//!   per-offer fee in the shielded token. Fees are paid in DUST outside
//!   the shielded offer (via [`crate::dust`]).
//! - [`ledger_adapter`] — translates a recipe into a
//!   `moonproof_ledger::zswap::Offer<ProofPreimage, D>`, embeds it in a
//!   `Transaction`, and runs the prover for the three zswap circuits.
//! - [`sync`] — chain-state replay from the indexer's
//!   `shieldedTransactions` subscription.
//!
//! Slices land incrementally — modules are added here as each slice
//! ships. `state` and `balances` are the first clean slice.

pub mod balances;
pub mod contract_call_balancer;
pub mod ledger_adapter;
pub mod state;
pub mod sync;
pub mod transacting;

pub use balances::{
    available_coins, pending_coins, total_coins, wallet_balance, AvailableCoin, PendingCoin,
    ShieldedBalanceSummary, ShieldedCoin,
};
pub use contract_call_balancer::{balance_contract_call_tx, build_shielded_balancing_tx};
pub use ledger_adapter::{
    build_shielded_offer, build_shielded_transaction, finalize_shielded_transaction,
    serialize_finalized_shielded_transaction, ShieldedFinalizedTransaction,
    ShieldedSignedTransaction,
};
pub use state::{InnerLocalState, ShieldedState};
pub use sync::{decode_zswap_event, replay_hex_zswap_events, replay_relevant_transactions};
pub use transacting::{
    build_shielded_init_swap_recipe, build_shielded_transfer_recipe, own_shielded_address,
    ShieldedInputCoin, ShieldedOutputSpec, ShieldedTransfer, ShieldedTransferRecipe,
    SHIELDED_COST_MODEL,
};