Skip to content

Commit

Permalink
Only apply &ohttp param to v2 URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Jan 9, 2024
1 parent 3b17e4e commit 270bfb7
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions payjoin-cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,16 @@ impl App {
};

let pj_uri_string = format!(
"{}?amount={}&pj={}&ohttp={}",
"{}?amount={}&pj={}",
pj_receiver_address.to_qr_uri(),
amount.to_btc(),
pj_part,
);

#[cfg(feature = "v2")]
let pj_uri_string = format!(
"{}&ohttp={}",
pj_uri_string,
self.config.ohttp_config,
);

Expand Down Expand Up @@ -775,6 +781,7 @@ pub(crate) struct AppConfig {
pub bitcoind_cookie: Option<String>,
pub bitcoind_rpcuser: String,
pub bitcoind_rpcpass: String,
#[cfg(feature = "v2")]
pub ohttp_config: String,
#[cfg(feature = "v2")]
pub ohttp_proxy: String,
Expand Down Expand Up @@ -808,6 +815,14 @@ impl AppConfig {
"bitcoind_rpcpass",
matches.get_one::<String>("rpcpass").map(|s| s.as_str()),
)?
// Subcommand defaults without which file serialization fails.
.set_default("pj_host", "0.0.0.0:3000")?
.set_default("pj_endpoint", "https://localhost:3000")?
.set_default("sub_only", false)?
.add_source(File::new("config.toml", FileFormat::Toml).required(false));

#[cfg(feature = "v2")]
let builder = builder
.set_default("ohttp_config", "")?
.set_override_option(
"ohttp_config",
Expand All @@ -817,12 +832,7 @@ impl AppConfig {
.set_override_option(
"ohttp_proxy",
matches.get_one::<String>("ohttp_proxy").map(|s| s.as_str()),
)?
// Subcommand defaults without which file serialization fails.
.set_default("pj_host", "0.0.0.0:3000")?
.set_default("pj_endpoint", "https://localhost:3000")?
.set_default("sub_only", false)?
.add_source(File::new("config.toml", FileFormat::Toml).required(false));
)?;

let builder = match matches.subcommand() {
Some(("send", _)) => builder,
Expand Down

0 comments on commit 270bfb7

Please sign in to comment.