diff --git a/zcash_proofs/CHANGELOG.md b/zcash_proofs/CHANGELOG.md index f44adad6b..8e80daf70 100644 --- a/zcash_proofs/CHANGELOG.md +++ b/zcash_proofs/CHANGELOG.md @@ -6,6 +6,9 @@ and this library adheres to Rust's notion of [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Replaced internal `directories` dependency which now transitively depends on + MPL-licensed code. ## [0.12.0] - 2023-06-06 ### Changed diff --git a/zcash_proofs/Cargo.toml b/zcash_proofs/Cargo.toml index 9930080d1..2e91476a5 100644 --- a/zcash_proofs/Cargo.toml +++ b/zcash_proofs/Cargo.toml @@ -34,9 +34,11 @@ tracing = "0.1" # Dependencies used internally: # (Breaking upgrades to these are usually backwards-compatible, but check MSRVs.) blake2b_simd = "1" -directories = { version = "5", optional = true } +home = { version = "0.5", optional = true } +known-folders = { version = "1", optional = true } redjubjub = "0.7" wagyu-zcash-parameters = { version = "0.2", optional = true } +xdg = { version = "2.5", optional = true } [dev-dependencies] byteorder = "1" @@ -49,6 +51,7 @@ pprof = { version = "0.11", features = ["criterion", "flamegraph"] } # MSRV 1.56 [features] default = ["local-prover", "multicore"] bundled-prover = ["wagyu-zcash-parameters"] +directories = ["dep:home", "dep:known-folders", "dep:xdg"] download-params = ["minreq", "directories"] local-prover = ["directories"] multicore = ["bellman/multicore", "zcash_primitives/multicore"] diff --git a/zcash_proofs/src/lib.rs b/zcash_proofs/src/lib.rs index 346fa48ad..a666f6e51 100644 --- a/zcash_proofs/src/lib.rs +++ b/zcash_proofs/src/lib.rs @@ -15,8 +15,6 @@ use std::fs::File; use std::io::{self, BufReader}; use std::path::Path; -#[cfg(feature = "directories")] -use directories::BaseDirs; #[cfg(feature = "directories")] use std::path::PathBuf; @@ -77,13 +75,23 @@ pub struct SaplingParameterPaths { #[cfg(feature = "directories")] #[cfg_attr(docsrs, doc(cfg(feature = "directories")))] pub fn default_params_folder() -> Option { - BaseDirs::new().map(|base_dirs| { - if cfg!(any(windows, target_os = "macos")) { - base_dirs.data_dir().join("ZcashParams") - } else { - base_dirs.home_dir().join(".zcash-params") - } - }) + #[cfg(windows)] + { + use known_folders::{get_known_folder_path, KnownFolder}; + get_known_folder_path(KnownFolder::RoamingAppData).map(|base| base.join("ZcashParams")) + } + + #[cfg(target_os = "macos")] + { + xdg::BaseDirectories::new() + .ok() + .map(|base_dirs| base_dirs.get_data_home().join("ZcashParams")) + } + + #[cfg(not(any(windows, target_os = "macos")))] + { + home::home_dir().map(|base| base.join(".zcash-params")) + } } /// Download the Zcash Sapling parameters if needed, and store them in the default location.