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, feature(doc_auto_cfg))]
59// Catch documentation errors caused by code changes.
60#![deny(rustdoc::broken_intra_doc_links)]
61// Temporary until we have addressed all Result<T, ()> cases.
62#![allow(clippy::result_unit_err)]
63
64pub mod data_api;
65mod decrypt;
66pub mod fees;
67pub mod proposal;
68pub mod proto;
69pub mod scan;
70pub mod scanning;
71pub mod wallet;
72
73#[cfg(feature = "sync")]
74pub mod sync;
75
76#[cfg(feature = "unstable-serialization")]
77pub mod serialization;
78
79#[cfg(feature = "tor")]
80pub mod tor;
81
82pub use decrypt::{decrypt_transaction, DecryptedOutput, TransferType};
83
84#[deprecated(note = "This module is deprecated; use `::zcash_keys::address` instead.")]
85pub mod address {
86 pub use zcash_keys::address::*;
87}
88#[deprecated(note = "This module is deprecated; use `::zcash_keys::encoding` instead.")]
89pub mod encoding {
90 pub use zcash_keys::encoding::*;
91}
92#[deprecated(note = "This module is deprecated; use `::zcash_keys::keys` instead.")]
93pub mod keys {
94 pub use zcash_keys::keys::*;
95}
96#[deprecated(note = "use ::zcash_protocol::PoolType instead")]
97pub type PoolType = zcash_protocol::PoolType;
98#[deprecated(note = "use ::zcash_protocol::ShieldedProtocol instead")]
99pub type ShieldedProtocol = zcash_protocol::ShieldedProtocol;
100#[deprecated(note = "This module is deprecated; use the `zip321` crate instead.")]
101pub mod zip321 {
102 pub use zip321::*;
103}
104
105#[cfg(test)]
106#[macro_use]
107extern crate assert_matches;