Browse Source

Serialization

checkpoints
Aditya Kulkarni 5 years ago
parent
commit
81b6b52ba0
  1. 2
      rust-lightclient/Cargo.toml
  2. 32
      rust-lightclient/src/lightwallet.rs

2
rust-lightclient/Cargo.toml

@ -20,7 +20,7 @@ tower-util = "0.1"
hex = "0.3"
protobuf = "2"
rustyline = "5.0.2"
byteorder = "1"
[dependencies.bellman]
git = "https://github.com/adityapk00/librustzcash.git"

32
rust-lightclient/src/lightwallet.rs

@ -1,4 +1,7 @@
use std::time::SystemTime;
use std::io::{self, Read, Write};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use pairing::bls12_381::Bls12;
use zcash_primitives::primitives::{Diversifier, Note, PaymentAddress};
@ -53,6 +56,29 @@ struct BlockData {
tree: CommitmentTree<Node>,
}
impl BlockData {
pub fn read<R: Read>(mut reader: R) -> io::Result<Self> {
let height = reader.read_i32::<LittleEndian>()?;
let mut hash_bytes = [0; 32];
reader.read_exact(&mut hash_bytes)?;
let tree = CommitmentTree::<Node>::read(&mut reader)?;
Ok(BlockData{
height,
hash: BlockHash{ 0: hash_bytes },
tree
})
}
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
writer.write_i32::<LittleEndian>(self.height)?;
writer.write_all(&self.hash.0)?;
self.tree.write(writer)
}
}
pub struct SaplingNoteData {
account: usize,
diversifier: Diversifier,
@ -79,6 +105,7 @@ impl SaplingNoteData {
nf
};
SaplingNoteData {
account: output.account,
diversifier: output.to.diversifier,
@ -89,7 +116,10 @@ impl SaplingNoteData {
memo: None
}
}
}
fn print_note(&self) {
}
pub struct WalletTx {
block: i32,

Loading…
Cancel
Save