moonproof-wallet 0.2.2

Native Rust wallet for the Midnight blockchain — HD derivation, coin balancing, Zswap/unshielded/dust transacting
Documentation
//! Native Rust wallet for the Midnight blockchain.
//!
//! Port of `@midnight-ntwrk/wallet-sdk` built on the `midnight-ledger` Rust
//! crates. The goal is full parity with the TypeScript SDK — HD key
//! derivation, coin balancing, Zswap / unshielded / dust sub-wallets, and
//! the orchestrating facade — without the WASM boundary.
//!
//! Crate layout:
//!
//! - [`hd`] — BIP32/BIP44 derivation with Midnight's role scheme. Verified
//!   against BIP32 Test Vector 1 for byte-for-byte interop with `@scure/bip32`.
//! - [`balancer`] — greedy + counter-offer coin balancer, 1:1 with the TS
//!   reference. Pluggable [`balancer::CoinSelector`]; default
//!   [`balancer::SmallestFirstSelector`] is a single-pass, zero-alloc
//!   `Iterator::min_by_key`.
//! - [`address`] — Bech32m address formats (shielded, unshielded, dust)
//!   with SCALE-compact big-integer encoding for dust.
//! - [`abstractions`] — `NetworkId`, `ProtocolVersion`, `SyncProgress`,
//!   `WalletSeed` — the cross-cutting primitives sub-wallets share.
//! - [`types`] — value types: `TokenType`, `Amount` (i128),
//!   `CoinRecipe` trait, `TransactionCostModel`.
//! - [`error`] — `WalletError` enum and crate-wide `Result` alias.
//! - [`shielded`] / [`unshielded`] / [`dust`] — the three sub-wallet state
//!   machines (pure `(state, input) -> state` transitions, no I/O).
//! - [`facade`] — composite state over the three sub-wallets plus
//!   transfer / swap / registration / submission orchestration.
//! - [`session`] — network connect, indexer-driven sync, and submit
//!   helpers for long-lived hosts.
//! - [`snapshot`] — persistence envelope for capture/restore of the
//!   facade state across process restarts.

pub mod abstractions;
pub mod address;
pub mod balancer;
pub mod connector;
pub mod display;
pub mod dust;
pub mod error;
pub mod facade;
pub mod hd;
pub mod keystore_addresses;
pub mod pending_tx;
pub mod runtime;
pub mod session;
pub mod shielded;
pub mod signing;
pub mod snapshot;
pub mod testing;
pub mod tx_history;
pub mod types;
pub mod unshielded;

pub use abstractions::{
    NetworkId, ProtocolVersion, ProtocolVersionRange, SyncProgress, WalletSeed,
};
pub use address::{
    DustAddress, MidnightBech32m, ShieldedAddress, ShieldedCoinPublicKey,
    ShieldedEncryptionPublicKey, ShieldedEncryptionSecretKey, UnshieldedAddress,
};
pub use balancer::{
    balance, BalanceRecipe, BalanceRequest, CoinSelector, CounterOffer, FewestCoinsSelector,
    Imbalances, OutputRecipe, SmallestFirstSelector,
};
pub use display::{format_dust, format_night};
pub use dust::{
    available_coins as dust_available_coins,
    available_coins_with_generated_dust as dust_available_coins_with_generated_dust,
    build_dust_balancing_intent, build_dust_generation_intent, build_dust_generation_recipe,
    build_dust_transaction, compute_fee_balancing_recipe, estimate_dust_generation,
    finalize_dust_only_transaction, finalize_with_proving_provider, find_available_segment_id,
    generation_info as dust_generation_info, next_segment_id_after,
    pending_coins as dust_pending_coins, serialize_finalized_dust_transaction,
    serialize_signed_dust_transaction, sign_dust_intent, sign_dust_intent_multi, split_night_utxos,
    total_coins as dust_total_coins, used_segment_ids, wallet_balance as dust_wallet_balance,
    CoinWithFee, DustBalancingRecipe, DustFullInfo, DustGenerationDetails, DustGenerationRecipe,
    DustIntent, DustRegistrationSpec, DustState, FinalizedDustTransaction, NightUtxoForDust,
    PendingDustSpend, SignedDustTransaction, SyncProgressUpdate, UnprovenDustSpend,
    UtxoWithDustEstimate,
};
pub use error::{Result, WalletError};
pub use facade::{
    balance_dust_fee, balance_unbound_transaction, build_combined_outputs,
    build_deregistration_recipe, build_dust_balancing_tx, build_init_swap_recipe,
    build_registration_recipe, build_transfer_recipe as build_facade_transfer_recipe,
    ended_transaction_result, fetch_chain_parameters, finalize_recipe, finalized_tx_handles,
    fold_dust_events, fold_shielded_ticks, fold_unshielded_ticks, has_dust_balancing_intent,
    init_swap, parse_shielded_token_label, parse_unshielded_token_label, serialize_finalized,
    sign_recipe, submit_finalized, transaction_result, ChainParameters, CombinedTokenTransfer,
    FacadeState, FacadeSyncProgress, FeeContext, FinalizedTransaction, FinalizedTransactionRecipe,
    FinalizedTxHandles, ProvenTransaction, RegistrationParams, ShieldedTokenTransfer,
    SignedRegistrationRecipe, SubmissionEnd, SubmissionOptions, SubmissionWatch, SwapInputs,
    SwapOptions, SwapSigningKeys, TransferOptions, TransferSigningKeys, UnprovenTransaction,
    UnprovenTransactionRecipe, UnshieldedTokenTransfer, UnsignedRegistrationRecipe,
};
pub use facade::{
    balance_sealed_recipe, balance_unbound_recipe, balance_unproven_transaction,
    finalize_sealed_recipe, finalize_unbound_recipe, imbalances_of, sign_unshielded_inputs,
    SealedBalancingRecipe, TransactionImbalances, UnboundBalancingRecipe,
};
pub use hd::{AccountKey, CompositeRoleKey, HDWallet, Role, RoleKey, SecretKey};
pub use keystore_addresses::derive_addresses;
pub use pending_tx::{
    InMemoryPendingTransactionsStorage, NoOpPendingTransactionsStorage, PendingTransactionEntry,
    PendingTransactionResult, PendingTransactionStatus, PendingTransactionsStorage, SegmentResult,
};
pub use signing::{
    sign_data, sign_raw, signed_message, verify_data, DataEncoding, InProcessSigner, SignCallback,
    SignedDataOutput,
};
pub use snapshot::{
    DustSnapshot, ShieldedSnapshot, UnshieldedSnapshot, WalletSnapshot, SNAPSHOT_FORMAT_VERSION,
};
pub use testing::{Wallet, GENESIS_MINT_WALLET_SEED_HEX};
pub use tx_history::{
    InMemoryTransactionHistoryStorage, NoOpTransactionHistoryStorage, TransactionHash,
    TransactionHistoryEntry, TransactionHistoryStatus, TransactionHistoryStorage,
};
pub use types::{Amount, CoinRecipe, SimpleCoin, TokenType, TransactionCostModel};
pub use unshielded::{
    build_init_swap_unshielded_recipe, build_transfer_recipe, BalanceSummary, TransferRecipe,
    UnshieldedOutputSpec, UnshieldedState, UnshieldedTransfer, UnshieldedUpdate, UnshieldedUtxo,
    UpdateStatus, UtxoId, UtxoMeta, UtxoWithMeta,
};