Expand description
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. Pluggablebalancer::CoinSelector; defaultbalancer::SmallestFirstSelectoris a single-pass, zero-allocIterator::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),CoinRecipetrait,TransactionCostModel.error—WalletErrorenum and crate-wideResultalias.shielded/unshielded/dust— the three sub-wallet state machines (pure(state, input) -> statetransitions, 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.
Re-exports§
pub use abstractions::NetworkId;pub use abstractions::ProtocolVersion;pub use abstractions::ProtocolVersionRange;pub use abstractions::SyncProgress;pub use abstractions::WalletSeed;pub use address::DustAddress;pub use address::MidnightBech32m;pub use address::ShieldedAddress;pub use address::ShieldedCoinPublicKey;pub use address::ShieldedEncryptionPublicKey;pub use address::ShieldedEncryptionSecretKey;pub use address::UnshieldedAddress;pub use balancer::balance;pub use balancer::BalanceRecipe;pub use balancer::BalanceRequest;pub use balancer::CoinSelector;pub use balancer::CounterOffer;pub use balancer::FewestCoinsSelector;pub use balancer::Imbalances;pub use balancer::OutputRecipe;pub use balancer::SmallestFirstSelector;pub use display::format_dust;pub use display::format_night;pub use dust::available_coins as dust_available_coins;pub use dust::available_coins_with_generated_dust as dust_available_coins_with_generated_dust;pub use dust::build_dust_balancing_intent;pub use dust::build_dust_generation_intent;pub use dust::build_dust_generation_recipe;pub use dust::build_dust_transaction;pub use dust::compute_fee_balancing_recipe;pub use dust::estimate_dust_generation;pub use dust::finalize_dust_only_transaction;pub use dust::finalize_with_proving_provider;pub use dust::find_available_segment_id;pub use dust::generation_info as dust_generation_info;pub use dust::next_segment_id_after;pub use dust::pending_coins as dust_pending_coins;pub use dust::serialize_finalized_dust_transaction;pub use dust::serialize_signed_dust_transaction;pub use dust::sign_dust_intent;pub use dust::sign_dust_intent_multi;pub use dust::split_night_utxos;pub use dust::total_coins as dust_total_coins;pub use dust::used_segment_ids;pub use dust::wallet_balance as dust_wallet_balance;pub use dust::CoinWithFee;pub use dust::DustBalancingRecipe;pub use dust::DustFullInfo;pub use dust::DustGenerationDetails;pub use dust::DustGenerationRecipe;pub use dust::DustIntent;pub use dust::DustRegistrationSpec;pub use dust::DustState;pub use dust::FinalizedDustTransaction;pub use dust::NightUtxoForDust;pub use dust::PendingDustSpend;pub use dust::SignedDustTransaction;pub use dust::SyncProgressUpdate;pub use dust::UnprovenDustSpend;pub use dust::UtxoWithDustEstimate;pub use error::Result;pub use error::WalletError;pub use facade::balance_dust_fee;pub use facade::balance_unbound_transaction;pub use facade::build_combined_outputs;pub use facade::build_deregistration_recipe;pub use facade::build_dust_balancing_tx;pub use facade::build_init_swap_recipe;pub use facade::build_registration_recipe;pub use facade::build_transfer_recipe as build_facade_transfer_recipe;pub use facade::ended_transaction_result;pub use facade::fetch_chain_parameters;pub use facade::finalize_recipe;pub use facade::finalized_tx_handles;pub use facade::fold_dust_events;pub use facade::fold_shielded_ticks;pub use facade::fold_unshielded_ticks;pub use facade::has_dust_balancing_intent;pub use facade::init_swap;pub use facade::parse_shielded_token_label;pub use facade::parse_unshielded_token_label;pub use facade::serialize_finalized;pub use facade::sign_recipe;pub use facade::submit_finalized;pub use facade::transaction_result;pub use facade::ChainParameters;pub use facade::CombinedTokenTransfer;pub use facade::FacadeState;pub use facade::FacadeSyncProgress;pub use facade::FeeContext;pub use facade::FinalizedTransaction;pub use facade::FinalizedTransactionRecipe;pub use facade::FinalizedTxHandles;pub use facade::ProvenTransaction;pub use facade::RegistrationParams;pub use facade::ShieldedTokenTransfer;pub use facade::SignedRegistrationRecipe;pub use facade::SubmissionEnd;pub use facade::SubmissionOptions;pub use facade::SubmissionWatch;pub use facade::SwapInputs;pub use facade::SwapOptions;pub use facade::SwapSigningKeys;pub use facade::TransferOptions;pub use facade::TransferSigningKeys;pub use facade::UnprovenTransaction;pub use facade::UnprovenTransactionRecipe;pub use facade::UnshieldedTokenTransfer;pub use facade::UnsignedRegistrationRecipe;pub use facade::balance_sealed_recipe;pub use facade::balance_unbound_recipe;pub use facade::balance_unproven_transaction;pub use facade::finalize_sealed_recipe;pub use facade::finalize_unbound_recipe;pub use facade::imbalances_of;pub use facade::sign_unshielded_inputs;pub use facade::SealedBalancingRecipe;pub use facade::TransactionImbalances;pub use facade::UnboundBalancingRecipe;pub use hd::AccountKey;pub use hd::CompositeRoleKey;pub use hd::HDWallet;pub use hd::Role;pub use hd::RoleKey;pub use hd::SecretKey;pub use keystore_addresses::derive_addresses;pub use pending_tx::InMemoryPendingTransactionsStorage;pub use pending_tx::NoOpPendingTransactionsStorage;pub use pending_tx::PendingTransactionEntry;pub use pending_tx::PendingTransactionResult;pub use pending_tx::PendingTransactionStatus;pub use pending_tx::PendingTransactionsStorage;pub use pending_tx::SegmentResult;pub use signing::sign_data;pub use signing::sign_raw;pub use signing::signed_message;pub use signing::verify_data;pub use signing::DataEncoding;pub use signing::InProcessSigner;pub use signing::SignCallback;pub use signing::SignedDataOutput;pub use snapshot::DustSnapshot;pub use snapshot::ShieldedSnapshot;pub use snapshot::UnshieldedSnapshot;pub use snapshot::WalletSnapshot;pub use snapshot::SNAPSHOT_FORMAT_VERSION;pub use testing::Wallet;pub use testing::GENESIS_MINT_WALLET_SEED_HEX;pub use tx_history::InMemoryTransactionHistoryStorage;pub use tx_history::NoOpTransactionHistoryStorage;pub use tx_history::TransactionHash;pub use tx_history::TransactionHistoryEntry;pub use tx_history::TransactionHistoryStatus;pub use tx_history::TransactionHistoryStorage;pub use types::Amount;pub use types::CoinRecipe;pub use types::SimpleCoin;pub use types::TokenType;pub use types::TransactionCostModel;pub use unshielded::build_init_swap_unshielded_recipe;pub use unshielded::build_transfer_recipe;pub use unshielded::BalanceSummary;pub use unshielded::TransferRecipe;pub use unshielded::UnshieldedOutputSpec;pub use unshielded::UnshieldedState;pub use unshielded::UnshieldedTransfer;pub use unshielded::UnshieldedUpdate;pub use unshielded::UnshieldedUtxo;pub use unshielded::UpdateStatus;pub use unshielded::UtxoId;pub use unshielded::UtxoMeta;pub use unshielded::UtxoWithMeta;
Modules§
- abstractions
- Cross-cutting abstractions shared by the sub-wallets.
- address
- Midnight address formats — Bech32m with a
mnHRP. - balancer
- Midnight coin-balancer — the greedy + counter-offer loop used by all three sub-wallets (shielded, unshielded, dust) to resolve a partially specified transaction into a concrete (inputs, outputs) recipe.
- connector
- The wallet side of
@midnightntwrk/dapp-connector-api4.1. - display
- Human-readable formatting of on-chain atomic amounts.
- dust
- Dust sub-wallet — port of
@midnight-ntwrk/wallet-sdk-dust-wallet. - error
- facade
- Wallet facade — the orchestrating layer over the three sub-wallets.
- hd
- BIP32 + BIP44 HD derivation for Midnight wallets.
- keystore_
addresses - Seed-to-public-address derivation. Takes a 64-byte BIP39 seed plus
a network ID and produces the
KeystoreAddressesbundle stored alongside the encrypted seed in the on-disk envelope. - pending_
tx - Pending-transaction tracking — port of
@midnight-ntwrk/wallet-sdk-capabilities/pendingTransactions. - runtime
- Long-lived sync coordinator on top of the facade.
- session
- Session-level wallet orchestration: pick a network, derive a wallet from a seed, sync facade state, prove + sign + submit recipes.
- shielded
- Shielded (Zswap) wallet sub-surface.
- signing
- Standalone signing primitives matching the dApp-connector-api
signDatasurface. - snapshot
- Persistent snapshot of a
crate::FacadeState. - testing
- Deterministic test-wallet helpers. Not a secret-key generator — do not use with real mnemonics.
- tx_
history - Transaction-history storage — port of
@midnight-ntwrk/wallet-sdk-abstractions/TransactionHistoryStorage. - types
- Public value types shared across the wallet crate.
- unshielded
- Unshielded (public) wallet sub-surface.