Drop `lsps1_service` cfg flag
What changed, and why it matters
This commit removes a Rust compile-time feature flag named `lsps1_service` from the `lightning-liquidity` crate. Previously, LSPS1 server-side code was only included when that flag was set. Now it is always compiled in. This is a build and API cleanup change, not a security fix. There is no indication in the commit or supplied references that this addresses a vulnerability.
No security action required. Treat as a normal build/API maintenance change. Reviewers may want to confirm that always enabling LSPS1 service code does not unexpectedly increase binary size or expose server-only APIs in client-only builds, but this is a product decision, not a security defect.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch drops the #[cfg(lsps1_service)] conditional-compilation guards across lightning-liquidity, making the LSPS1 service handler, events, persistence, and integration tests always available. It also removes the flag from Cargo.toml’s check-cfg list and from the CI script. The change simplifies the crate’s feature surface and ensures LSPS1 service code is compiled by default. No bug fixes, bounds checks, or cryptographic changes are present.
Changed components
lightning-liquidity crate build configurationlightning-liquidity/src/manager.rslightning-liquidity/src/events/mod.rslightning-liquidity/src/lsps1/event.rslightning-liquidity/src/lsps1/mod.rslightning-liquidity/src/lsps1/msgs.rslightning-liquidity/src/persist.rslightning-liquidity/Cargo.tomlci/ci-tests-cfg-flags.shInspect captured patch +5 / −53
diff --git a/ci/ci-tests-cfg-flags.sh b/ci/ci-tests-cfg-flags.sh
index 5380c98..2bdc94b 100755
--- a/ci/ci-tests-cfg-flags.sh
+++ b/ci/ci-tests-cfg-flags.sh
@@ -9,6 +9,4 @@ RUSTFLAGS="--cfg=taproot" cargo test --quiet --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=simple_close" cargo test --quiet --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
-RUSTFLAGS="--cfg=lsps1_service" cargo test --quiet --color always -p lightning-liquidity
-[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=peer_storage" cargo test --quiet --color always -p lightning
diff --git a/lightning-liquidity/Cargo.toml b/lightning-liquidity/Cargo.toml
index 61f41c1..cc7fb0c 100644
--- a/lightning-liquidity/Cargo.toml
+++ b/lightning-liquidity/Cargo.toml
@@ -46,7 +46,6 @@ parking_lot = { version = "0.12", default-features = false }
level = "forbid"
# When adding a new cfg attribute, ensure that it is added to this list.
check-cfg = [
- "cfg(lsps1_service)",
"cfg(c_bindings)",
"cfg(backtrace)",
"cfg(ldk_bench)",
diff --git a/lightning-liquidity/src/events/mod.rs b/lightning-liquidity/src/events/mod.rs
index c39b8b9..3d9587a 100644
--- a/lightning-liquidity/src/events/mod.rs
+++ b/lightning-liquidity/src/events/mod.rs
@@ -33,7 +33,6 @@ pub enum LiquidityEvent {
/// An LSPS1 (Channel Request) client event.
LSPS1Client(lsps1::event::LSPS1ClientEvent),
/// An LSPS1 (Channel Request) server event.
- #[cfg(lsps1_service)]
LSPS1Service(lsps1::event::LSPS1ServiceEvent),
/// An LSPS2 (JIT Channel) client event.
LSPS2Client(lsps2::event::LSPS2ClientEvent),
@@ -57,7 +56,6 @@ impl From<lsps1::event::LSPS1ClientEvent> for LiquidityEvent {
}
}
-#[cfg(lsps1_service)]
impl From<lsps1::event::LSPS1ServiceEvent> for LiquidityEvent {
fn from(event: lsps1::event::LSPS1ServiceEvent) -> Self {
Self::LSPS1Service(event)
diff --git a/lightning-liquidity/src/lsps1/event.rs b/lightning-liquidity/src/lsps1/event.rs
index c9a1844..d78d6d9 100644
--- a/lightning-liquidity/src/lsps1/event.rs
+++ b/lightning-liquidity/src/lsps1/event.rs
@@ -143,7 +143,6 @@ pub enum LSPS1ClientEvent {
}
/// An event which an LSPS1 server should take some action in response to.
-#[cfg(lsps1_service)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum LSPS1ServiceEvent {
/// A client has selected the parameters to use from the supported options of the LSP
diff --git a/lightning-liquidity/src/lsps1/mod.rs b/lightning-liquidity/src/lsps1/mod.rs
index 2270abe..5f7f554 100644
--- a/lightning-liquidity/src/lsps1/mod.rs
+++ b/lightning-liquidity/src/lsps1/mod.rs
@@ -12,7 +12,5 @@
pub mod client;
pub mod event;
pub mod msgs;
-#[cfg(lsps1_service)]
pub(crate) mod peer_state;
-#[cfg(lsps1_service)]
pub mod service;
diff --git a/lightning-liquidity/src/lsps1/msgs.rs b/lightning-liquidity/src/lsps1/msgs.rs
index a2382e0..eae9568 100644
--- a/lightning-liquidity/src/lsps1/msgs.rs
+++ b/lightning-liquidity/src/lsps1/msgs.rs
@@ -31,9 +31,7 @@ pub(crate) const LSPS1_CREATE_ORDER_METHOD_NAME: &str = "lsps1.create_order";
pub(crate) const LSPS1_GET_ORDER_METHOD_NAME: &str = "lsps1.get_order";
pub(crate) const _LSPS1_CREATE_ORDER_REQUEST_INVALID_PARAMS_ERROR_CODE: i32 = -32602;
-#[cfg(lsps1_service)]
pub(crate) const LSPS1_CREATE_ORDER_REQUEST_ORDER_MISMATCH_ERROR_CODE: i32 = 100;
-#[cfg(lsps1_service)]
pub(crate) const LSPS1_GET_ORDER_REQUEST_ORDER_NOT_FOUND_ERROR_CODE: i32 = 101;
pub(crate) const LSPS1_CREATE_ORDER_REQUEST_UNRECOGNIZED_OR_STALE_TOKEN_ERROR_CODE: i32 = 102;
diff --git a/lightning-liquidity/src/manager.rs b/lightning-liquidity/src/manager.rs
index 99a0c8f..f1b098d 100644
--- a/lightning-liquidity/src/manager.rs
+++ b/lightning-liquidity/src/manager.rs
@@ -23,15 +23,13 @@ use crate::lsps5::client::{LSPS5ClientConfig, LSPS5ClientHandler};
use crate::lsps5::msgs::LSPS5Message;
use crate::lsps5::service::{LSPS5ServiceConfig, LSPS5ServiceHandler};
use crate::message_queue::MessageQueue;
-#[cfg(lsps1_service)]
-use crate::persist::read_lsps1_service_peer_states;
use crate::persist::{
- read_event_queue, read_lsps2_service_peer_states, read_lsps5_service_peer_states,
+ read_event_queue, read_lsps1_service_peer_states, read_lsps2_service_peer_states,
+ read_lsps5_service_peer_states,
};
use crate::lsps1::client::{LSPS1ClientConfig, LSPS1ClientHandler};
use crate::lsps1::msgs::LSPS1Message;
-#[cfg(lsps1_service)]
use crate::lsps1::service::{LSPS1ServiceConfig, LSPS1ServiceHandler, LSPS1ServiceHandlerSync};
use crate::lsps2::client::{LSPS2ClientConfig, LSPS2ClientHandler};
@@ -73,7 +71,6 @@ const LSPS_FEATURE_BIT: usize = 729;
#[derive(Clone)]
pub struct LiquidityServiceConfig {
/// Optional server-side configuration for LSPS1 channel requests.
- #[cfg(lsps1_service)]
pub lsps1_service_config: Option<LSPS1ServiceConfig>,
/// Optional server-side configuration for JIT channels
/// should you want to support them.
@@ -284,7 +281,6 @@ pub struct LiquidityManager<
ignored_peers: RwLock<HashSet<PublicKey>>,
lsps0_client_handler: LSPS0ClientHandler<ES, K>,
lsps0_service_handler: Option<LSPS0ServiceHandler>,
- #[cfg(lsps1_service)]
lsps1_service_handler: Option<LSPS1ServiceHandler<ES, CM, K, TP>>,
lsps1_client_handler: Option<LSPS1ClientHandler<ES, K>>,
lsps2_service_handler: Option<LSPS2ServiceHandler<CM, K, T>>,
@@ -451,7 +447,6 @@ where
})
});
- #[cfg(lsps1_service)]
let lsps1_service_handler = if let Some(service_config) = service_config.as_ref() {
if let Some(lsps1_service_config) = service_config.lsps1_service_config.as_ref() {
if let Some(number) =
@@ -499,7 +494,6 @@ where
lsps0_client_handler,
lsps0_service_handler,
lsps1_client_handler,
- #[cfg(lsps1_service)]
lsps1_service_handler,
lsps2_client_handler,
lsps2_service_handler,
@@ -530,7 +524,6 @@ where
}
/// Returns a reference to the LSPS1 server-side handler.
- #[cfg(lsps1_service)]
pub fn lsps1_service_handler(&self) -> Option<&LSPS1ServiceHandler<ES, CM, K, TP>> {
self.lsps1_service_handler.as_ref()
}
@@ -634,7 +627,6 @@ where
let mut did_persist = false;
did_persist |= self.pending_events.persist().await?;
- #[cfg(lsps1_service)]
if let Some(lsps1_service_handler) = self.lsps1_service_handler.as_ref() {
did_persist |= lsps1_service_handler.persist().await?;
}
@@ -680,18 +672,15 @@ where
},
}
},
- LSPSMessage::LSPS1(_msg @ LSPS1Message::Request(..)) => {
- #[cfg(lsps1_service)]
+ LSPSMessage::LSPS1(msg @ LSPS1Message::Request(..)) => {
match &self.lsps1_service_handler {
Some(lsps1_service_handler) => {
- lsps1_service_handler.handle_message(_msg, sender_node_id)?;
+ lsps1_service_handler.handle_message(msg, sender_node_id)?;
},
None => {
return Err(LightningError { err: format!("Received LSPS1 request message without LSPS1 service handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
}
- #[cfg(not(lsps1_service))]
- return Err(LightningError { err: format!("Received LSPS1 request message without LSPS1 service handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
LSPSMessage::LSPS2(msg @ LSPS2Message::Response(..)) => {
match &self.lsps2_client_handler {
@@ -732,14 +721,10 @@ where
.lsps2_service_handler
.as_ref()
.is_some_and(|h| h.has_active_requests(sender_node_id));
- #[cfg(lsps1_service)]
let lsps1_has_active_orders = self
.lsps1_service_handler
.as_ref()
.is_some_and(|h| h.has_active_orders(sender_node_id));
- #[cfg(not(lsps1_service))]
- let lsps1_has_active_orders = false;
-
lsps5_service_handler.enforce_prior_activity_or_reject(
sender_node_id,
lsps2_has_active_requests,
@@ -895,7 +880,6 @@ where
// If the peer was misbehaving, drop it from the ignored list to cleanup the kept state.
self.ignored_peers.write().unwrap().remove(&counterparty_node_id);
- #[cfg(lsps1_service)]
if let Some(lsps1_service_handler) = self.lsps1_service_handler.as_ref() {
lsps1_service_handler.peer_disconnected(counterparty_node_id);
}
@@ -1051,7 +1035,6 @@ where
/// Returns a reference to the LSPS1 server-side handler.
///
/// Wraps [`LiquidityManager::lsps1_service_handler`].
- #[cfg(lsps1_service)]
pub fn lsps1_service_handler<'a>(
&'a self,
) -> Option<LSPS1ServiceHandlerSync<'a, ES, CM, KVStoreSyncWrapper<KS>, TP>> {
diff --git a/lightning-liquidity/src/persist.rs b/lightning-liquidity/src/persist.rs
index 13afdab..30d7824 100644
--- a/lightning-liquidity/src/persist.rs
+++ b/lightning-liquidity/src/persist.rs
@@ -10,7 +10,6 @@
//! Types and utils for persistence.
use crate::events::{EventQueueDeserWrapper, LiquidityEvent};
-#[cfg(lsps1_service)]
use crate::lsps1::peer_state::PeerState as LSPS1ServicePeerState;
use crate::lsps2::service::PeerState as LSPS2ServicePeerState;
use crate::lsps5::service::PeerState as LSPS5ServicePeerState;
@@ -44,7 +43,6 @@ pub const LIQUIDITY_MANAGER_EVENT_QUEUE_PERSISTENCE_KEY: &str = "event_queue";
/// The secondary namespace under which the [`LSPS1ServiceHandler`] data will be persisted.
///
/// [`LSPS1ServiceHandler`]: crate::lsps1::service::LSPS1ServiceHandler
-#[cfg(lsps1_service)]
pub const LSPS1_SERVICE_PERSISTENCE_SECONDARY_NAMESPACE: &str = "lsps1_service";
/// The secondary namespace under which the [`LSPS2ServiceHandler`] data will be persisted.
@@ -88,7 +86,6 @@ pub(crate) async fn read_event_queue<K: KVStore>(
Ok(Some(queue.0))
}
-#[cfg(lsps1_service)]
pub(crate) async fn read_lsps1_service_peer_states<K: KVStore>(
kv_store: K,
) -> Result<HashMap<PublicKey, Mutex<LSPS1ServicePeerState>>, lightning::io::Error> {
diff --git a/lightning-liquidity/tests/lsps0_integration_tests.rs b/lightning-liquidity/tests/lsps0_integration_tests.rs
index 58d9e86..c2e94e3 100644
--- a/lightning-liquidity/tests/lsps0_integration_tests.rs
+++ b/lightning-liquidity/tests/lsps0_integration_tests.rs
@@ -6,11 +6,8 @@ use common::{create_service_and_client_nodes, get_lsps_message, LSPSNodes};
use lightning_liquidity::events::LiquidityEvent;
use lightning_liquidity::lsps0::event::LSPS0ClientEvent;
-#[cfg(lsps1_service)]
use lightning_liquidity::lsps1::client::LSPS1ClientConfig;
-#[cfg(lsps1_service)]
use lightning_liquidity::lsps1::msgs::LSPS1Options;
-#[cfg(lsps1_service)]
use lightning_liquidity::lsps1::service::LSPS1ServiceConfig;
use lightning_liquidity::lsps2::client::LSPS2ClientConfig;
use lightning_liquidity::lsps2::service::LSPS2ServiceConfig;
@@ -35,7 +32,6 @@ fn list_protocols_integration_test() {
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let promise_secret = [42; 32];
let lsps2_service_config = LSPS2ServiceConfig { promise_secret };
- #[cfg(lsps1_service)]
let lsps1_service_config = {
let supported_options = LSPS1Options {
min_required_channel_confirmations: 0,
@@ -53,7 +49,6 @@ fn list_protocols_integration_test() {
};
let lsps5_service_config = LSPS5ServiceConfig::default();
let service_config = LiquidityServiceConfig {
- #[cfg(lsps1_service)]
lsps1_service_config: Some(lsps1_service_config),
lsps2_service_config: Some(lsps2_service_config),
lsps5_service_config: Some(lsps5_service_config),
@@ -61,14 +56,10 @@ fn list_protocols_integration_test() {
};
let lsps2_client_config = LSPS2ClientConfig::default();
- #[cfg(lsps1_service)]
let lsps1_client_config: LSPS1ClientConfig = LSPS1ClientConfig { max_channel_fees_msat: None };
let lsps5_client_config = LSPS5ClientConfig::default();
let client_config = LiquidityClientConfig {
- #[cfg(lsps1_service)]
lsps1_client_config: Some(lsps1_client_config),
- #[cfg(not(lsps1_service))]
- lsps1_client_config: None,
lsps2_client_config: Some(lsps2_client_config),
lsps5_client_config: Some(lsps5_client_config),
};
@@ -107,16 +98,12 @@ fn list_protocols_integration_test() {
protocols,
}) => {
assert_eq!(counterparty_node_id, client_node_id);
- #[cfg(lsps1_service)]
{
assert!(protocols.contains(&1));
assert!(protocols.contains(&2));
assert!(protocols.contains(&5));
assert_eq!(protocols.len(), 3);
}
-
- #[cfg(not(lsps1_service))]
- assert_eq!(protocols, vec![2, 5]);
},
_ => panic!("Unexpected event"),
}
diff --git a/lightning-liquidity/tests/lsps1_integration_tests.rs b/lightning-liquidity/tests/lsps1_integration_tests.rs
index 8cd7f28..d2ca559 100644
--- a/lightning-liquidity/tests/lsps1_integration_tests.rs
+++ b/lightning-liquidity/tests/lsps1_integration_tests.rs
@@ -1,4 +1,4 @@
-#![cfg(all(test, feature = "time", lsps1_service))]
+#![cfg(all(test, feature = "time"))]
mod common;
diff --git a/lightning-liquidity/tests/lsps2_integration_tests.rs b/lightning-liquidity/tests/lsps2_integration_tests.rs
index 1c37f16..47be70f 100644
--- a/lightning-liquidity/tests/lsps2_integration_tests.rs
+++ b/lightning-liquidity/tests/lsps2_integration_tests.rs
@@ -60,7 +60,6 @@ fn build_lsps2_configs() -> ([u8; 32], LiquidityServiceConfig, LiquidityClientCo
let promise_secret = [42; 32];
let lsps2_service_config = LSPS2ServiceConfig { promise_secret };
let service_config = LiquidityServiceConfig {
- #[cfg(lsps1_service)]
lsps1_service_config: None,
lsps2_service_config: Some(lsps2_service_config),
lsps5_service_config: None,
@@ -941,7 +940,6 @@ fn lsps2_service_handler_persistence_across_restarts() {
let promise_secret = [42; 32];
let service_config = LiquidityServiceConfig {
- #[cfg(lsps1_service)]
lsps1_service_config: None,
lsps2_service_config: Some(LSPS2ServiceConfig { promise_secret }),
lsps5_service_config: None,
diff --git a/lightning-liquidity/tests/lsps5_integration_tests.rs b/lightning-liquidity/tests/lsps5_integration_tests.rs
index 6af0c13..2b32b4d 100644
--- a/lightning-liquidity/tests/lsps5_integration_tests.rs
+++ b/lightning-liquidity/tests/lsps5_integration_tests.rs
@@ -52,7 +52,6 @@ pub(crate) fn lsps5_test_setup_with_kv_stores<'a, 'b, 'c>(
) -> (LSPSNodes<'a, 'b, 'c>, LSPS5Validator) {
let lsps5_service_config = LSPS5ServiceConfig::default();
let service_config = LiquidityServiceConfig {
- #[cfg(lsps1_service)]
lsps1_service_config: None,
lsps2_service_config: None,
lsps5_service_config: Some(lsps5_service_config),
@@ -236,7 +235,6 @@ pub(crate) fn lsps5_lsps2_test_setup<'a, 'b, 'c>(
let lsps5_service_config = LSPS5ServiceConfig::default();
let lsps2_service_config = LSPS2ServiceConfig { promise_secret: [42; 32] };
let service_config = LiquidityServiceConfig {
- #[cfg(lsps1_service)]
lsps1_service_config: None,
lsps2_service_config: Some(lsps2_service_config),
lsps5_service_config: Some(lsps5_service_config),
@@ -1512,7 +1510,6 @@ fn lsps5_service_handler_persistence_across_restarts() {
let client_kv_store = Arc::new(TestStore::new(false));
let service_config = LiquidityServiceConfig {
- #[cfg(lsps1_service)]
lsps1_service_config: None,
lsps2_service_config: None,
lsps5_service_config: Some(LSPS5ServiceConfig::default()),
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.