Expand description
§Zcash Wallet Interchange Format (ZeWIF)
zewif
is a library that defines a standard data format for migrating wallet data
between different Zcash wallet implementations. It provides a comprehensive set of
types, tools, and utilities for serializing, deserializing, and manipulating Zcash
wallet data in a way that preserves all critical information during migration.
§Core Features
- Complete Wallet Data Model: Represents all aspects of a Zcash wallet including accounts, addresses, transactions, and keys
- Multi-Protocol Support: Handles the Transparent, Sapling, and Orchard Zcash protocols.
- Type-Safe Representation: Uses Rust’s type system to ensure correct handling of Zcash concepts
- Extensible Metadata: Supports custom metadata through an attachments system
§Core Components
The ZeWIF format is organized hierarchically:
Zewif
: The root container holding wallets and global transaction dataZewifWallet
: Individual wallet with accounts and network contextTransaction
: Complete transaction data (inputs, outputs, metadata)
§Protocol Support
ZeWIF handles the Zcash protocol versions:
- Transparent: Bitcoin-compatible public transactions ([
TransparentAddress
], [TxIn
], [TxOut
]) - Sapling: Improved shielded protocol (
sapling
module,sapling::SaplingSentOutput
, etc.) - Orchard: Latest shielded protocol (
orchard
module,orchard::OrchardSentOutput
, etc.)
§Integration Path
This crate is part of a larger ecosystem:
zewif
: Core library defining the interchange format (this crate)zmigrate
: Command-line tool for wallet migrationszewif-zcashd
: ZCashd-specific integration for migrationzewif-zingo
: Zingo-specific integration for migration (future)
§Usage Examples
use zewif::{Zewif, ZewifWallet, Network, Account, Address, BlockHeight};
// Create a new ZeWIF container
let mut zewif = Zewif::new(BlockHeight::from_u32(2000000));
// Create a new wallet for the main network
let mut wallet = ZewifWallet::new(Network::Main);
// Add a new account to the wallet
let mut account = Account::new();
account.set_name("Default Account");
// Add the account to the wallet and the wallet to the ZeWIF container
wallet.add_account(account);
zewif.add_wallet(wallet);
Modules§
- orchard
- sapling
- Sapling Protocol Components
- transparent
- Zcash transparent wallet data.
Macros§
- blob
- Creates a new type wrapping a fixed-size byte array with common methods and trait implementations.
- blob_
envelope - data
- Creates a new type wrapping a variable-size byte array with common methods and trait implementations.
- mod_use
- A macro that simplifies module declarations and re-exports in a single statement.
- string
- Creates a new type wrapping a String with common methods and trait implementations.
- test_
cbor_ roundtrip - test_
envelope_ roundtrip
Structs§
- Account
- A logical grouping of addresses and transaction history within a wallet.
- Address
- A high-level address representation with metadata in a Zcash wallet.
- Amount
- A type-safe representation of a ZCash amount in zatoshis (zats).
- Anchor
- A root of either the Sapling or Orchard Zcash note commitment trees.
- Bip39
Mnemonic - Blob
- A fixed-size byte array wrapper for safely handling binary data of known length.
- Block
Hash - A transaction identifier (BlockHash) represented as a 32-byte hash.
- Block
Height - A block’s position in the blockchain, represented as a distance from the genesis block.
- Data
- A variable-size byte array wrapper for safely handling binary data of arbitrary length.
- Derivation
Info - Hierarchical deterministic (HD) derivation information for wallet addresses.
- Incremental
Witness - A Merkle path to a specific note commitment in a Merkle tree, along with metadata about the state of the tree at the time the Merkle path was computed.
- Memo
- A memo associated with a Zcash shielded output.
- NonHardened
Child Index - A non-hardened index used in hierarchical deterministic wallet derivation paths.
- Script
- A Bitcoin-style script for spending or encumbering coins in transparent transactions.
- Seed
- A pre-BIP-39 seed, 32 bytes long
- Seed
Fingerprint - The fingerprint of an HD seed, as defined in ZIP 32
- Transaction
- A Zcash transaction that can combine transparent and multiple shielded protocol components.
- TxBlock
Position - The unique identifier of a transaction on the blockchain in terms of the hash of the block that includes it and the index of the transaction within the block.
- TxId
- A transaction identifier (TxId) represented as a 32-byte hash.
- Unified
Address - A multi-protocol Zcash address that can contain components from different Zcash protocols.
- Zewif
- The top-level container for the Zcash Wallet Interchange Format (ZeWIF).
- Zewif
Envelope - Zewif
Wallet - A complete Zcash wallet with multiple accounts and cryptographic key material.
Enums§
- HexParse
Error - Errors that can occur in decoding a blob from its hex-encoded representation.
- Mnemonic
Language - The language used for BIP-39/BIP-44 mnemonic seed phrases in a wallet.
- Network
- Represents a Zcash network environment (mainnet, testnet, or regtest).
- Protocol
Address - A protocol-specific Zcash address representation without additional metadata.
- Seed
Material - Source material used to generate cryptographic keys in a Zcash wallet.
Constants§
- COIN
- Number of zatoshis (zats) in 1 ZEC
- H0
- The height of the genesis block on a network.
- MAX_
BALANCE - Maximum balance as a signed value
- MAX_
MONEY - Maximum possible ZEC supply in zatoshis (21 million ZEC)
Traits§
Functions§
- envelope_
indexed_ objects_ for_ predicate - envelope_
optional_ indexed_ objects_ for_ predicate - format_
signed_ zats_ as_ zec - Formats a signed zatoshi amount as a human-readable ZEC value with appropriate sign.
- format_
with_ underscores - Formats a number with underscores as thousand separators for improved readability.
- format_
zats_ as_ zec - Formats an amount in zatoshi (smallest Zcash unit) as a human-readable ZEC value.
- set_
indexes - test_
cbor_ roundtrip - test_
envelope_ roundtrip