mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-01-30 18:42:15 +00:00
Serialization
This commit is contained in:
parent
4d78c3f4ac
commit
81b6b52ba0
@ -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"
|
||||
|
@ -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…
Reference in New Issue
Block a user