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/// public lightwalletd endpoints for fallback
16pub const LIGHTWALLETD_MAINNET: &str = "https://mainnet.lightwalletd.com:9067";
17pub const LIGHTWALLETD_MAINNET_ALT: &str = "https://lightwalletd.electriccoin.co:9067";
18pub const LIGHTWALLETD_TESTNET: &str = "https://testnet.lightwalletd.com:9067";
19
20/// generated protobuf types for zidecar
21#[cfg(feature = "client")]
22pub mod zidecar_proto {
23    tonic::include_proto!("zidecar.v1");
24}
25
26/// generated protobuf types for lightwalletd
27#[cfg(feature = "client")]
28pub mod lightwalletd_proto {
29    tonic::include_proto!("cash.z.wallet.sdk.rpc");
30}
31
32/// sync status from server
33#[derive(Debug, Clone)]
34pub struct SyncStatus {
35    pub current_height: u32,
36    pub current_epoch: u32,
37    pub blocks_in_epoch: u32,
38    pub complete_epochs: u32,
39    pub epoch_proof_ready: bool,
40    pub blocks_until_ready: u32,
41    pub last_epoch_proof_height: u32,
42}
43
44/// tree state at a block height
45#[derive(Debug, Clone)]
46pub struct TreeState {
47    pub height: u32,
48    pub hash: Vec<u8>,
49    pub time: u64,
50    pub sapling_tree: String,
51    pub orchard_tree: String,
52}
53
54/// transparent UTXO
55#[derive(Debug, Clone)]
56pub struct Utxo {
57    pub address: String,
58    pub txid: [u8; 32],
59    pub output_index: u32,
60    pub script: Vec<u8>,
61    pub value_zat: u64,
62    pub height: u32,
63}
64
65/// send transaction response
66#[derive(Debug, Clone)]
67pub struct SendResult {
68    pub txid: String,
69    pub error_code: i32,
70    pub error_message: String,
71}
72
73impl SendResult {
74    pub fn is_success(&self) -> bool {
75        self.error_code == 0
76    }
77}
78
79/// compact block for wallet scanning
80#[derive(Debug, Clone)]
81pub struct CompactBlock {
82    pub height: u32,
83    pub hash: Vec<u8>,
84    pub actions: Vec<CompactAction>,
85}
86
87/// compact orchard action for trial decryption
88#[derive(Debug, Clone)]
89pub struct CompactAction {
90    pub cmx: [u8; 32],
91    pub ephemeral_key: [u8; 32],
92    pub ciphertext: Vec<u8>,
93    pub nullifier: [u8; 32],
94}