mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-01-31 02:52:14 +00:00
Serialization
This commit is contained in:
parent
4d78c3f4ac
commit
81b6b52ba0
@ -20,7 +20,7 @@ tower-util = "0.1"
|
|||||||
hex = "0.3"
|
hex = "0.3"
|
||||||
protobuf = "2"
|
protobuf = "2"
|
||||||
rustyline = "5.0.2"
|
rustyline = "5.0.2"
|
||||||
|
byteorder = "1"
|
||||||
|
|
||||||
[dependencies.bellman]
|
[dependencies.bellman]
|
||||||
git = "https://github.com/adityapk00/librustzcash.git"
|
git = "https://github.com/adityapk00/librustzcash.git"
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
use std::io::{self, Read, Write};
|
||||||
|
|
||||||
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
|
|
||||||
use pairing::bls12_381::Bls12;
|
use pairing::bls12_381::Bls12;
|
||||||
use zcash_primitives::primitives::{Diversifier, Note, PaymentAddress};
|
use zcash_primitives::primitives::{Diversifier, Note, PaymentAddress};
|
||||||
@ -53,6 +56,29 @@ struct BlockData {
|
|||||||
tree: CommitmentTree<Node>,
|
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 {
|
pub struct SaplingNoteData {
|
||||||
account: usize,
|
account: usize,
|
||||||
diversifier: Diversifier,
|
diversifier: Diversifier,
|
||||||
@ -79,6 +105,7 @@ impl SaplingNoteData {
|
|||||||
nf
|
nf
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SaplingNoteData {
|
SaplingNoteData {
|
||||||
account: output.account,
|
account: output.account,
|
||||||
diversifier: output.to.diversifier,
|
diversifier: output.to.diversifier,
|
||||||
@ -89,6 +116,9 @@ impl SaplingNoteData {
|
|||||||
memo: None
|
memo: None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_note(&self) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WalletTx {
|
pub struct WalletTx {
|
||||||
|
Loading…
Reference in New Issue
Block a user