Skip to content

Commit

Permalink
f Remove unused config args
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesraa committed Jun 24, 2024
1 parent 7306025 commit 3027793
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 39 deletions.
47 changes: 16 additions & 31 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ struct LiquiditySourceConfig {

#[derive(Debug, Clone)]
struct PayjoinConfig {
#[allow(dead_code)]
payjoin_directory: String,
payjoin_relay: String,
#[allow(dead_code)]
ohttp_keys: Option<String>,
payjoin_relay: payjoin::Url,
}

impl Default for LiquiditySourceConfig {
Expand Down Expand Up @@ -267,10 +263,11 @@ impl NodeBuilder {

/// Configures the [`Node`] instance to enable payjoin transactions.
pub fn set_payjoin_config(
&mut self, payjoin_directory: String, payjoin_relay: String, ohttp_keys: Option<String>,
) -> &mut Self {
self.payjoin_config = Some(PayjoinConfig { payjoin_directory, payjoin_relay, ohttp_keys });
self
&mut self, payjoin_relay: String
) -> Result<&mut Self, BuildError> {
let payjoin_relay = payjoin::Url::parse(&payjoin_relay).map_err(|_| BuildError::InvalidPayjoinConfig)?;
self.payjoin_config = Some(PayjoinConfig { payjoin_relay });
Ok(self)
}

/// Configures the [`Node`] instance to source its inbound liquidity from the given
Expand Down Expand Up @@ -483,13 +480,11 @@ impl ArcedNodeBuilder {

/// Configures the [`Node`] instance to enable payjoin transactions.
pub fn set_payjoin_config(
&self, payjoin_directory: String, payjoin_relay: String, ohttp_keys: Option<String>,
) {
&self, payjoin_relay: String,
) -> Result<(), BuildError> {
self.inner.write().unwrap().set_payjoin_config(
payjoin_directory,
payjoin_relay,
ohttp_keys,
);
).map(|_| ())
}

/// Configures the [`Node`] instance to source its gossip data from the given RapidGossipSync
Expand Down Expand Up @@ -1007,23 +1002,13 @@ fn build_with_store_internal(
let (event_handling_stopped_sender, _) = tokio::sync::watch::channel(());

let mut payjoin_sender = None;
if let Some((_payjoin_directory, payjoin_relay, _ohttp_keys)) = payjoin_config
.as_ref()
.map(|pc| (pc.payjoin_directory.clone(), pc.payjoin_relay.clone(), pc.ohttp_keys.clone()))
{
match PayjoinSender::new(
Arc::clone(&logger),
Arc::clone(&wallet),
Arc::clone(&tx_broadcaster),
&payjoin_relay,
) {
Ok(payjoin_sender_) => {
payjoin_sender = Some(Arc::new(payjoin_sender_));
},
Err(_) => {
return Err(BuildError::InvalidPayjoinConfig);
},
}
if let Some(pj_config) = payjoin_config {
payjoin_sender = Some(Arc::new(PayjoinSender::new(
Arc::clone(&logger),
Arc::clone(&wallet),
Arc::clone(&tx_broadcaster),
pj_config.payjoin_relay.clone(),
)));
}

let is_listening = Arc::new(AtomicBool::new(false));
Expand Down
11 changes: 3 additions & 8 deletions src/payjoin_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@ where
B::Target: BroadcasterInterface,
{
pub(crate) fn new(
logger: Arc<FilesystemLogger>, wallet: Arc<Wallet>, broadcaster: B, payjoin_relay: &str,
) -> Result<Self, Error> {
if let Ok(payjoin_relay) = payjoin::Url::parse(&payjoin_relay) {
Ok(Self { logger, wallet, broadcaster, payjoin_relay })
} else {
log_error!(logger, "The provided payjoin relay URL is invalid.");
Err(Error::PayjoinSenderUnavailable)
}
logger: Arc<FilesystemLogger>, wallet: Arc<Wallet>, broadcaster: B, payjoin_relay: payjoin::Url,
) -> Self {
Self { logger, wallet, broadcaster, payjoin_relay }
}

pub(crate) fn create_payjoin_request(
Expand Down

0 comments on commit 3027793

Please sign in to comment.