mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-01-29 02:02:14 +00:00
Embed sapling params
This commit is contained in:
parent
68731b0f9f
commit
48bf5f3f63
@ -38,7 +38,7 @@ webpki-roots = "0.16.0"
|
||||
tower-h2 = { git = "https://github.com/tower-rs/tower-h2" }
|
||||
openssl = "*"
|
||||
openssl-probe = "*"
|
||||
|
||||
rust-embed = "5.1.0"
|
||||
|
||||
[dependencies.bellman]
|
||||
git = "https://github.com/adityapk00/librustzcash.git"
|
||||
@ -72,4 +72,4 @@ tower-grpc-build = { git = "https://github.com/tower-rs/tower-grpc", features =
|
||||
rand_core = "0.5.1"
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
debug = false
|
@ -37,6 +37,7 @@ use zcash_client_backend::{
|
||||
use crate::grpc_client::{ChainSpec, BlockId, BlockRange, RawTransaction,
|
||||
TransparentAddressBlockFilter, TxFilter, Empty, LightdInfo};
|
||||
use crate::grpc_client::client::CompactTxStreamer;
|
||||
use crate::SaplingParams;
|
||||
|
||||
// Used below to return the grpc "Client" type to calling methods
|
||||
|
||||
@ -142,8 +143,6 @@ macro_rules! make_grpc_client {
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct LightClientConfig {
|
||||
pub server : http::Uri,
|
||||
@ -153,22 +152,6 @@ pub struct LightClientConfig {
|
||||
}
|
||||
|
||||
impl LightClientConfig {
|
||||
pub fn get_params_path(&self, name: &str) -> Box<Path> {
|
||||
let mut params_location;
|
||||
|
||||
if cfg!(target_os="macos") || cfg!(target_os="windows") {
|
||||
params_location = dirs::data_dir()
|
||||
.expect("Couldn't determine app data directory!");
|
||||
params_location.push("ZcashParams");
|
||||
} else {
|
||||
params_location = dirs::home_dir()
|
||||
.expect("Couldn't determine home directory!");
|
||||
params_location.push(".zcash-params");
|
||||
};
|
||||
|
||||
params_location.push(name);
|
||||
params_location.into_boxed_path()
|
||||
}
|
||||
|
||||
pub fn get_zcash_data_path(&self) -> Box<Path> {
|
||||
let mut zcash_data_location;
|
||||
@ -335,19 +318,8 @@ impl LightClient {
|
||||
info!("Read wallet with birthday {}", lc.wallet.get_first_tx_block());
|
||||
|
||||
// Read Sapling Params
|
||||
let mut f = match File::open(config.get_params_path("sapling-output.params")) {
|
||||
Ok(file) => file,
|
||||
Err(_) => return Err(Error::new(ErrorKind::NotFound,
|
||||
format!("Couldn't read {}", config.get_params_path("sapling-output.params").display())))
|
||||
};
|
||||
f.read_to_end(&mut lc.sapling_output)?;
|
||||
|
||||
let mut f = match File::open(config.get_params_path("sapling-spend.params")) {
|
||||
Ok(file) => file,
|
||||
Err(_) => return Err(Error::new(ErrorKind::NotFound,
|
||||
format!("Couldn't read {}", config.get_params_path("sapling-spend.params").display())))
|
||||
};
|
||||
f.read_to_end(&mut lc.sapling_spend)?;
|
||||
lc.sapling_output.extend_from_slice(SaplingParams::get("sapling-output.params").unwrap().as_ref());
|
||||
lc.sapling_spend.extend_from_slice(SaplingParams::get("sapling-spend.params").unwrap().as_ref());
|
||||
|
||||
info!("Created LightClient to {}", &config.server);
|
||||
println!("Lightclient connecting to {}", config.server);
|
||||
|
@ -1228,24 +1228,17 @@ pub mod tests {
|
||||
use super::LightWallet;
|
||||
use crate::LightClientConfig;
|
||||
use secp256k1::{Secp256k1, key::PublicKey, key::SecretKey};
|
||||
use crate::SaplingParams;
|
||||
|
||||
fn get_sapling_params(config: &LightClientConfig) -> Result<(Vec<u8>, Vec<u8>), Error> {
|
||||
// Read Sapling Params
|
||||
let mut sapling_output = vec![];
|
||||
let mut f = match File::open(config.get_params_path("sapling-output.params")) {
|
||||
Ok(file) => file,
|
||||
Err(_) => return Err(Error::new(ErrorKind::NotFound,
|
||||
format!("Couldn't read {}", config.get_params_path("sapling-output.params").display())))
|
||||
};
|
||||
f.read_to_end(&mut sapling_output)?;
|
||||
sapling_output.extend_from_slice(SaplingParams::get("sapling-output.params").unwrap().as_ref());
|
||||
println!("Read output {}", sapling_output.len());
|
||||
|
||||
let mut sapling_spend = vec![];
|
||||
let mut f = match File::open(config.get_params_path("sapling-spend.params")) {
|
||||
Ok(file) => file,
|
||||
Err(_) => return Err(Error::new(ErrorKind::NotFound,
|
||||
format!("Couldn't read {}", config.get_params_path("sapling-spend.params").display())))
|
||||
};
|
||||
f.read_to_end(&mut sapling_spend)?;
|
||||
sapling_spend.extend_from_slice(SaplingParams::get("sapling-spend.params").unwrap().as_ref());
|
||||
println!("Read output {}", sapling_spend.len());
|
||||
|
||||
Ok((sapling_spend, sapling_output))
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
#[macro_use]
|
||||
extern crate rust_embed;
|
||||
|
||||
mod lightclient;
|
||||
mod lightwallet;
|
||||
mod address;
|
||||
@ -24,6 +27,10 @@ pub mod grpc_client {
|
||||
include!(concat!(env!("OUT_DIR"), "/cash.z.wallet.sdk.rpc.rs"));
|
||||
}
|
||||
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "zcash-params/"]
|
||||
pub struct SaplingParams;
|
||||
|
||||
pub fn main() {
|
||||
// Get command line arguments
|
||||
let matches = App::new("ZecLite CLI")
|
||||
|
BIN
zcash-params/sapling-output.params
Normal file
BIN
zcash-params/sapling-output.params
Normal file
Binary file not shown.
BIN
zcash-params/sapling-spend.params
Normal file
BIN
zcash-params/sapling-spend.params
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user