Skip to main content

lightwallet_protocol/
lib.rs

1//! Rust bindings for Zcash lightwallet protocol buffers.
2//!
3//! This crate provides auto-generated Rust bindings for the Zcash lightwallet
4//! protocol buffer definitions, including both the gRPC service definitions
5//! and the compact block format messages.
6
7// Include the generated protobuf code
8pub mod cash {
9    pub mod z {
10        pub mod wallet {
11            pub mod sdk {
12                pub mod rpc {
13                    include!("generated/cash.z.wallet.sdk.rpc.rs");
14                }
15            }
16        }
17    }
18}
19
20// Re-export commonly used types at the crate root for convenience
21pub use cash::z::wallet::sdk::rpc::*;
22
23// Re-export service traits and types for the gRPC service
24pub use cash::z::wallet::sdk::rpc::compact_tx_streamer_client::CompactTxStreamerClient;
25pub use cash::z::wallet::sdk::rpc::compact_tx_streamer_server::{
26    CompactTxStreamer, CompactTxStreamerServer,
27};
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32
33    #[test]
34    fn test_block_id_creation() {
35        let block_id = BlockId {
36            height: 1000,
37            hash: vec![0x00, 0x01, 0x02],
38        };
39        assert_eq!(block_id.height, 1000);
40        assert_eq!(block_id.hash, vec![0x00, 0x01, 0x02]);
41    }
42
43    #[test]
44    fn test_compact_block_creation() {
45        let block = CompactBlock {
46            proto_version: 1,
47            height: 500000,
48            hash: vec![0xaa, 0xbb],
49            prev_hash: vec![0xcc, 0xdd],
50            time: 1234567890,
51            header: vec![],
52            vtx: vec![],
53            chain_metadata: None,
54        };
55        assert_eq!(block.height, 500000);
56        assert_eq!(block.time, 1234567890);
57    }
58
59    #[test]
60    fn test_raw_transaction() {
61        let tx = RawTransaction {
62            data: vec![0x01, 0x02, 0x03],
63            height: 42,
64        };
65        assert_eq!(tx.data, vec![0x01, 0x02, 0x03]);
66        assert_eq!(tx.height, 42);
67    }
68}