Crate zewif

Source
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 data
    • ZewifWallet: Individual wallet with accounts and network context
      • Account: Logical grouping of addresses and transaction references
        • Address: Individual addresses of various types (transparent, shielded, unified)
    • Transaction: Complete transaction data (inputs, outputs, metadata)

§Protocol Support

ZeWIF handles the Zcash protocol versions:

§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 migrations
  • zewif-zcashd: ZCashd-specific integration for migration
  • zewif-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.
Bip39Mnemonic
Blob
A fixed-size byte array wrapper for safely handling binary data of known length.
BlockHash
A transaction identifier (BlockHash) represented as a 32-byte hash.
BlockHeight
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.
DerivationInfo
Hierarchical deterministic (HD) derivation information for wallet addresses.
IncrementalWitness
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.
NonHardenedChildIndex
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
SeedFingerprint
The fingerprint of an HD seed, as defined in ZIP 32
Transaction
A Zcash transaction that can combine transparent and multiple shielded protocol components.
TxBlockPosition
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.
UnifiedAddress
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).
ZewifEnvelope
ZewifWallet
A complete Zcash wallet with multiple accounts and cryptographic key material.

Enums§

HexParseError
Errors that can occur in decoding a blob from its hex-encoded representation.
MnemonicLanguage
The language used for BIP-39/BIP-44 mnemonic seed phrases in a wallet.
Network
Represents a Zcash network environment (mainnet, testnet, or regtest).
ProtocolAddress
A protocol-specific Zcash address representation without additional metadata.
SeedMaterial
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§

Indexed
RandomInstance
SetIndexes

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

Type Aliases§

Blob20
Type alias for Blob<20>
Blob32
Type alias for Blob<32>
Blob64
Type alias for Blob<64>