zcash_client_backend/lib.rs
1//! *A crate for implementing Zcash light clients.*
2//!
3//! `zcash_client_backend` contains Rust structs and traits for creating shielded Zcash
4//! light clients.
5//!
6//! # Design
7//!
8//! ## Wallet sync
9//!
10//! The APIs in the [`data_api::chain`] module can be used to implement the following
11//! synchronization flow:
12//!
13//! ```text
14//! ┌─────────────┐ ┌─────────────┐
15//! │Get required │ │ Update │
16//! │subtree root │─▶│subtree roots│
17//! │ range │ └─────────────┘
18//! └─────────────┘ │
19//! ▼
20//! ┌─────────┐
21//! │ Update │
22//! ┌────────────────────────────────▶│chain tip│◀──────┐
23//! │ └─────────┘ │
24//! │ │ │
25//! │ ▼ │
26//! ┌─────────────┐ ┌────────────┐ ┌─────────────┐ │
27//! │ Truncate │ │Split range │ │Get suggested│ │
28//! │ wallet to │ │into batches│◀─│ scan ranges │ │
29//! │rewind height│ └────────────┘ └─────────────┘ │
30//! └─────────────┘ │ │
31//! ▲ ╱│╲ │
32//! │ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │
33//! ┌────────┐ ┌───────────────┐ │ │
34//! │ Choose │ │ │Download blocks│ │
35//! │ rewind │ │ to cache │ │ │
36//! │ height │ │ └───────────────┘ .───────────────────.
37//! └────────┘ │ │ ( Scan ranges updated )
38//! ▲ │ ▼ `───────────────────'
39//! │ ┌───────────┐ │ ▲
40//! .───────────────┴─. │Scan cached│ .─────────. │
41//! ( Continuity error )◀────│ blocks │──▶( Success )───────┤
42//! `───────────────┬─' └───────────┘ `─────────' │
43//! │ │ │
44//! │ ┌──────┴───────┐ │
45//! ▼ ▼ │ ▼
46//! │┌─────────────┐┌─────────────┐ ┌──────────────────────┐
47//! │Delete blocks││ Enhance ││ │Update wallet balance │
48//! ││ from cache ││transactions │ │ and sync progress │
49//! └─────────────┘└─────────────┘│ └──────────────────────┘
50//! └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
51//! ```
52//!
53//! ## Feature flags
54#![doc = document_features::document_features!()]
55//!
56
57#![cfg_attr(docsrs, feature(doc_cfg))]
58#![cfg_attr(docsrs, doc(auto_cfg))]
59// Catch documentation errors caused by code changes.
60#![deny(rustdoc::broken_intra_doc_links)]
61
62pub mod data_api;
63mod decrypt;
64pub mod fees;
65pub mod proposal;
66pub mod proto;
67pub mod scan;
68pub mod scanning;
69pub mod util;
70pub mod wallet;
71
72#[cfg(any(feature = "sync", feature = "sync-decryptor"))]
73pub mod sync;
74
75#[cfg(feature = "unstable-serialization")]
76pub mod serialization;
77
78#[cfg(feature = "sync-decryptor")]
79mod task;
80
81#[cfg(feature = "tor")]
82pub mod tor;
83
84pub use decrypt::{DecryptedOutput, TransferType, decrypt_transaction};
85
86#[deprecated(note = "This module is deprecated; use `::zcash_keys::address` instead.")]
87pub mod address {
88 pub use zcash_keys::address::*;
89}
90#[deprecated(note = "This module is deprecated; use `::zcash_keys::encoding` instead.")]
91pub mod encoding {
92 pub use zcash_keys::encoding::*;
93}
94#[deprecated(note = "This module is deprecated; use `::zcash_keys::keys` instead.")]
95pub mod keys {
96 pub use zcash_keys::keys::*;
97}
98#[deprecated(note = "use ::zcash_protocol::PoolType instead")]
99pub type PoolType = zcash_protocol::PoolType;
100#[deprecated(note = "use ::zcash_protocol::ShieldedPool instead")]
101pub type ShieldedPool = zcash_protocol::ShieldedPool;
102#[deprecated(note = "This module is deprecated; use the `zip321` crate instead.")]
103pub mod zip321 {
104 pub use zip321::*;
105}
106
107#[cfg(test)]
108#[macro_use]
109extern crate assert_matches;