Skip to main content

zync_core/client/
mod.rs

1//! gRPC clients for Zcash light wallet services
2//!
3//! provides unified interface for both zidecar (our server) and lightwalletd (public fallback)
4
5#[cfg(feature = "client")]
6mod lightwalletd;
7#[cfg(feature = "client")]
8mod zidecar;
9
10#[cfg(feature = "client")]
11pub use lightwalletd::LightwalletdClient;
12#[cfg(feature = "client")]
13pub use zidecar::ZidecarClient;
14
15// re-export endpoints from the non-gated module for backwards compat
16pub use crate::endpoints::*;
17
18/// generated protobuf types for zidecar
19#[cfg(feature = "client")]
20pub mod zidecar_proto {
21    tonic::include_proto!("zidecar.v1");
22}
23
24/// generated protobuf types for lightwalletd
25#[cfg(feature = "client")]
26pub mod lightwalletd_proto {
27    tonic::include_proto!("cash.z.wallet.sdk.rpc");
28}
29
30/// sync status from server
31#[derive(Debug, Clone)]
32pub struct SyncStatus {
33    pub current_height: u32,
34    pub current_epoch: u32,
35    pub blocks_in_epoch: u32,
36    pub complete_epochs: u32,
37    pub epoch_proof_ready: bool,
38    pub blocks_until_ready: u32,
39    pub last_epoch_proof_height: u32,
40}
41
42/// tree state at a block height
43#[derive(Debug, Clone)]
44pub struct TreeState {
45    pub height: u32,
46    pub hash: Vec<u8>,
47    pub time: u64,
48    pub sapling_tree: String,
49    pub orchard_tree: String,
50}
51
52/// transparent UTXO
53#[derive(Debug, Clone)]
54pub struct Utxo {
55    pub address: String,
56    pub txid: [u8; 32],
57    pub output_index: u32,
58    pub script: Vec<u8>,
59    pub value_zat: u64,
60    pub height: u32,
61}
62
63/// send transaction response
64#[derive(Debug, Clone)]
65pub struct SendResult {
66    pub txid: String,
67    pub error_code: i32,
68    pub error_message: String,
69}
70
71impl SendResult {
72    pub fn is_success(&self) -> bool {
73        self.error_code == 0
74    }
75}
76
77/// compact block for wallet scanning
78#[derive(Debug, Clone)]
79pub struct CompactBlock {
80    pub height: u32,
81    pub hash: Vec<u8>,
82    pub actions: Vec<CompactAction>,
83}
84
85/// compact orchard action for trial decryption
86#[derive(Debug, Clone)]
87pub struct CompactAction {
88    pub cmx: [u8; 32],
89    pub ephemeral_key: [u8; 32],
90    pub ciphertext: Vec<u8>,
91    pub nullifier: [u8; 32],
92}