Skip to main content

Crate zcash_client_backend

Crate zcash_client_backend 

Source
Expand description

A crate for implementing Zcash light clients.

zcash_client_backend contains Rust structs and traits for creating shielded Zcash light clients.

§Design

§Wallet sync

The APIs in the data_api::chain module can be used to implement the following synchronization flow:

                         ┌─────────────┐  ┌─────────────┐
                         │Get required │  │   Update    │
                         │subtree root │─▶│subtree roots│
                         │    range    │  └─────────────┘
                         └─────────────┘         │
                                                 ▼
                                            ┌─────────┐
                                            │ Update  │
          ┌────────────────────────────────▶│chain tip│◀──────┐
          │                                 └─────────┘       │
          │                                      │            │
          │                                      ▼            │
   ┌─────────────┐        ┌────────────┐  ┌─────────────┐     │
   │  Truncate   │        │Split range │  │Get suggested│     │
   │  wallet to  │        │into batches│◀─│ scan ranges │     │
   │rewind height│        └────────────┘  └─────────────┘     │
   └─────────────┘               │                            │
          ▲                     ╱│╲                           │
          │      ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─              │
     ┌────────┐         ┌───────────────┐       │             │
     │ Choose │  │      │Download blocks│                     │
     │ rewind │         │   to cache    │       │             │
     │ height │  │      └───────────────┘           .───────────────────.
     └────────┘                 │               │  ( Scan ranges updated )
          ▲      │              ▼                   `───────────────────'
          │               ┌───────────┐         │             ▲
 .───────────────┴─.      │Scan cached│    .─────────.        │
( Continuity error  )◀────│  blocks   │──▶(  Success  )───────┤
 `───────────────┬─'      └───────────┘    `─────────'        │
                                │               │             │
                 │       ┌──────┴───────┐                     │
                         ▼              ▼       │             ▼
                 │┌─────────────┐┌─────────────┐  ┌──────────────────────┐
                  │Delete blocks││   Enhance   ││ │Update wallet balance │
                 ││ from cache  ││transactions │  │  and sync progress   │
                  └─────────────┘└─────────────┘│ └──────────────────────┘
                 └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─

§Feature flags

  • lightwalletd-tonic — Enables the tonic gRPC client bindings for connecting to a lightwalletd server.

  • lightwalletd-tonic-tls-webpki-roots — Enables the tls-webpki-roots feature of tonic.

  • lightwalletd-tonic-transport — Enables the transport feature of tonic producing a fully-featured client and server implementation

  • transparent-inputs — Enables receiving transparent funds and shielding them.

  • spend-index — Enables per-outpoint transparent spend queries, for consumers that have access to a spent-outpoint index (e.g. a full node’s spend index). Adds the TransactionDataRequest::GetSpendingTx request variant and the WalletWrite::notify_output_verified_unspent method, and is what a wallet targeting such a data source enables instead of relying on address-based TransactionsInvolvingAddress requests for transparent spend detection.

  • orchard (enabled by default) — Enables receiving and spending Orchard funds.

    The orchard crate itself is an unconditional dependency (via zcash_primitives, which always requires it because every v5+ transaction carries an Orchard bundle type); this feature gates the wallet’s Orchard note-handling code, not the crate linkage.

  • zcashd-compat — Enables compatibility with legacy zcashd wallet data

  • pczt — Enables creating partially-constructed transactions for use in hardware wallet and multisig scenarios.

  • sync — Exposes a wallet synchronization function that implements the necessary state machine.

  • sync-decryptor — Exposes a batch decryption engine for use within syncing.

    This feature flag will eventually be removed when the sync::run function behind the sync feature flag is replaced with a sync engine that makes use of the batch decryption engine.

  • tor — Exposes a Tor client for hiding a wallet’s IP address while performing certain wallet operations.

  • test-dependencies — Exposes APIs that are useful for testing, such as proptest strategies.

    NOTE: Semver-breaking changes to the APIs exposed by this feature may be present in any release version, including patch releases.

  • non-standard-fees — Exposes APIs that allow calculation of non-standard fees.

§Experimental features

  • unstable — Exposes unstable APIs. Their behaviour may change at any time.
  • unstable-serialization — Exposes APIs for unstable serialization formats. These may change at any time.
  • unstable-spanning-tree — Exposes the data_api::scanning::spanning_tree module.

Modules§

addressDeprecated
data_api
Utilities for Zcash wallet construction
encodingDeprecated
fees
keysDeprecated
proposal
Types related to the construction and evaluation of transaction proposals.
proto
This module contains generated code for handling light client protobuf structs.
scan
scanning
Tools for scanning a compact representation of the Zcash block chain.
serializationunstable-serialization
syncsync-decryptor or sync
Implementation of the synchronization flow described in the crate root.
tortor
Tor support for Zcash wallets.
wallet
Structs representing transaction data scanned from the block chain by a wallet or light client.
zip321Deprecated

Structs§

DecryptedOutput
A decrypted shielded output.

Enums§

TransferType
An enumeration of the possible relationships a TXO can have to the wallet.

Functions§

decrypt_transaction
Scans a Transaction for any information that can be decrypted by the set of UnifiedFullViewingKeys.

Type Aliases§

PoolTypeDeprecated
ShieldedPoolDeprecated