diff --git a/lib/src/lightclient.rs b/lib/src/lightclient.rs index e669d45..fa96ce4 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -146,6 +146,9 @@ impl LightClientConfig { zcash_data_location = dirs::data_dir().expect("Couldn't determine app data directory!"); zcash_data_location.push("Zcash"); } else { + if dirs::home_dir().is_none() { + info!("Couldn't determine home dir!"); + } zcash_data_location = dirs::home_dir().expect("Couldn't determine home directory!"); zcash_data_location.push(".zcash"); }; @@ -174,6 +177,10 @@ impl LightClientConfig { } pub fn get_zcash_params_path(&self) -> io::Result> { + if dirs::home_dir().is_none() { + return Err(io::Error::new(io::ErrorKind::InvalidData, "Couldn't determine Home Dir")); + } + let mut zcash_params = self.get_zcash_data_path().into_path_buf(); zcash_params.push(".."); if cfg!(target_os="macos") || cfg!(target_os="windows") { @@ -375,24 +382,26 @@ impl LightClient { self.sapling_spend.extend_from_slice(sapling_spend); } - // Ensure that the sapling params are stored on disk properly as well. - match self.config.get_zcash_params_path() { - Ok(zcash_params_dir) => { - // Create the sapling output and spend params files - match LightClient::write_file_if_not_exists(&zcash_params_dir, "sapling-output.params", &self.sapling_output) { - Ok(_) => {}, - Err(e) => eprintln!("Warning: Couldn't write the output params!\n{}", e) - }; - - match LightClient::write_file_if_not_exists(&zcash_params_dir, "sapling-spend.params", &self.sapling_spend) { - Ok(_) => {}, - Err(e) => eprintln!("Warning: Couldn't write the output params!\n{}", e) + // Ensure that the sapling params are stored on disk properly as well. Only on desktop + if cfg!(all(not(target_os="ios"), not(target_os="android"))) { + match self.config.get_zcash_params_path() { + Ok(zcash_params_dir) => { + // Create the sapling output and spend params files + match LightClient::write_file_if_not_exists(&zcash_params_dir, "sapling-output.params", &self.sapling_output) { + Ok(_) => {}, + Err(e) => eprintln!("Warning: Couldn't write the output params!\n{}", e) + }; + + match LightClient::write_file_if_not_exists(&zcash_params_dir, "sapling-spend.params", &self.sapling_spend) { + Ok(_) => {}, + Err(e) => eprintln!("Warning: Couldn't write the output params!\n{}", e) + } + }, + Err(e) => { + eprintln!("{}", e); } - }, - Err(e) => { - eprintln!("{}", e); - } - }; + }; + } Ok(()) }