From ca02d140224b4dc19d3c37110beb52d08dea7e7b Mon Sep 17 00:00:00 2001 From: DanGould Date: Fri, 9 Aug 2024 23:22:15 -0400 Subject: [PATCH] Make hyper dependencies optional for v1 only --- payjoin-cli/Cargo.toml | 7 ++++--- payjoin-cli/src/app/mod.rs | 9 +-------- payjoin-cli/src/app/v1.rs | 9 ++++++++- payjoin-cli/src/main.rs | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/payjoin-cli/Cargo.toml b/payjoin-cli/Cargo.toml index b998daa5..edb4d477 100644 --- a/payjoin-cli/Cargo.toml +++ b/payjoin-cli/Cargo.toml @@ -21,6 +21,7 @@ path = "src/main.rs" [features] native-certs = ["reqwest/rustls-tls-native-roots"] danger-local-https = ["rcgen", "reqwest/rustls-tls", "rustls", "hyper-rustls", "payjoin/danger-local-https", "tokio-rustls"] +v1 = ["hyper", "hyper-util", "http-body-util"] v2 = ["payjoin/v2", "payjoin/io"] [dependencies] @@ -31,10 +32,10 @@ bitcoincore-rpc = "0.19.0" clap = { version = "~4.0.32", features = ["derive"] } config = "0.13.3" env_logger = "0.9.0" -http-body-util = "0.1" -hyper = { version = "1", features = ["full"] } +http-body-util = { version = "0.1", optional = true } +hyper = { version = "1", features = ["full"], optional = true } hyper-rustls = { version = "0.26", optional = true } -hyper-util = "0.1" +hyper-util = { version = "0.1", optional = true } log = "0.4.7" payjoin = { version = "0.19.0", features = ["send", "receive", "base64"] } rcgen = { version = "0.11.1", optional = true } diff --git a/payjoin-cli/src/app/mod.rs b/payjoin-cli/src/app/mod.rs index 9c68fdee..811f3b58 100644 --- a/payjoin-cli/src/app/mod.rs +++ b/payjoin-cli/src/app/mod.rs @@ -11,7 +11,7 @@ use payjoin::{bitcoin, PjUri}; pub mod config; use crate::app::config::AppConfig; -#[cfg(not(feature = "v2"))] +#[cfg(all(not(feature = "v2"), feature = "v1"))] pub(crate) mod v1; #[cfg(feature = "v2")] pub(crate) mod v2; @@ -126,13 +126,6 @@ fn try_contributing_inputs( Ok(()) } -struct Headers<'a>(&'a hyper::HeaderMap); -impl payjoin::receive::Headers for Headers<'_> { - fn get_header(&self, key: &str) -> Option<&str> { - self.0.get(key).map(|v| v.to_str()).transpose().ok().flatten() - } -} - #[cfg(feature = "danger-local-https")] fn http_agent() -> Result { Ok(http_agent_builder()?.build()?) } diff --git a/payjoin-cli/src/app/v1.rs b/payjoin-cli/src/app/v1.rs index b2b9bab5..0ce4cbb3 100644 --- a/payjoin-cli/src/app/v1.rs +++ b/payjoin-cli/src/app/v1.rs @@ -21,11 +21,18 @@ use tokio::net::TcpListener; use super::config::AppConfig; use super::App as AppTrait; -use crate::app::{http_agent, try_contributing_inputs, Headers}; +use crate::app::{http_agent, try_contributing_inputs}; use crate::db::Database; #[cfg(feature = "danger-local-https")] pub const LOCAL_CERT_FILE: &str = "localhost.der"; +struct Headers<'a>(&'a hyper::HeaderMap); +impl payjoin::receive::Headers for Headers<'_> { + fn get_header(&self, key: &str) -> Option<&str> { + self.0.get(key).map(|v| v.to_str()).transpose().ok().flatten() + } +} + #[derive(Clone)] pub(crate) struct App { config: AppConfig, diff --git a/payjoin-cli/src/main.rs b/payjoin-cli/src/main.rs index 2e60ce09..deb50d7a 100644 --- a/payjoin-cli/src/main.rs +++ b/payjoin-cli/src/main.rs @@ -7,7 +7,7 @@ use url::Url; mod app; mod db; -#[cfg(not(feature = "v2"))] +#[cfg(all(not(feature = "v2"), feature = "v1"))] use app::v1::App; #[cfg(feature = "v2")] use app::v2::App;