Browse Source

Write vector tkeys

master
Aditya Kulkarni 5 years ago
parent
commit
ba706ab7ce
  1. 6
      src/lightclient.rs
  2. 13
      src/lightwallet/mod.rs

6
src/lightclient.rs

@ -39,11 +39,9 @@ use crate::grpc_client::{ChainSpec, BlockId, BlockRange, RawTransaction,
use crate::grpc_client::client::CompactTxStreamer; use crate::grpc_client::client::CompactTxStreamer;
use crate::SaplingParams; use crate::SaplingParams;
// Used below to return the grpc "Client" type to calling methods
pub const DEFAULT_SERVER: &str = "https://lightd-main.zecwallet.co:443"; pub const DEFAULT_SERVER: &str = "https://lightd-main.zecwallet.co:443";
pub const WALLET_NAME: &str = "zeclite.wallet.dat"; pub const WALLET_NAME: &str = "zecwallet-light-wallet.dat";
pub const LOGFILE_NAME: &str = "zeclite.debug.log"; pub const LOGFILE_NAME: &str = "zecwallet-light-wallet.debug.log";
/// A Secure (https) grpc destination. /// A Secure (https) grpc destination.
struct Dst { struct Dst {

13
src/lightwallet/mod.rs

@ -216,9 +216,11 @@ impl LightWallet {
let addresses = extfvks.iter().map( |fvk| fvk.default_address().unwrap().1 ) let addresses = extfvks.iter().map( |fvk| fvk.default_address().unwrap().1 )
.collect::<Vec<PaymentAddress<Bls12>>>(); .collect::<Vec<PaymentAddress<Bls12>>>();
let tkeys = Vector::read(&mut reader, |r| {
let mut tpk_bytes = [0u8; 32]; let mut tpk_bytes = [0u8; 32];
reader.read_exact(&mut tpk_bytes)?; r.read_exact(&mut tpk_bytes)?;
let tpk = secp256k1::SecretKey::from_slice(&tpk_bytes).unwrap(); secp256k1::SecretKey::from_slice(&tpk_bytes).map_err(|e| io::Error::new(ErrorKind::InvalidData, e))
})?;
let blocks = Vector::read(&mut reader, |r| BlockData::read(r))?; let blocks = Vector::read(&mut reader, |r| BlockData::read(r))?;
@ -251,7 +253,7 @@ impl LightWallet {
extsks, extsks,
extfvks, extfvks,
address: addresses, address: addresses,
tkeys: vec![tpk], tkeys: tkeys,
blocks: Arc::new(RwLock::new(blocks)), blocks: Arc::new(RwLock::new(blocks)),
txs: Arc::new(RwLock::new(txs)), txs: Arc::new(RwLock::new(txs)),
config: config.clone(), config: config.clone(),
@ -272,8 +274,9 @@ impl LightWallet {
)?; )?;
// Write the transparent private key // Write the transparent private key
// TODO: This only writes the first key for now Vector::write(&mut writer, &self.tkeys,
writer.write_all(&self.tkeys[0][..])?; |w, pk| w.write_all(&pk[..])
)?;
Vector::write(&mut writer, &self.blocks.read().unwrap(), |w, b| b.write(w))?; Vector::write(&mut writer, &self.blocks.read().unwrap(), |w, b| b.write(w))?;

Loading…
Cancel
Save