Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit f65b378

Browse files
committed
Drop cfg(lsps1) flag
1 parent a11f2c4 commit f65b378

File tree

7 files changed

+18
-62
lines changed

7 files changed

+18
-62
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ jobs:
3636
run: |
3737
cargo doc --release
3838
cargo doc --no-default-features --features no-std
39-
RUSTFLAGS="--cfg lsps1" RUSTDOCFLAGS="--cfg lsps1" cargo doc --release
40-
RUSTFLAGS="--cfg lsps1" RUSTDOCFLAGS="--cfg lsps1" cargo doc --no-default-features --features no-std
4139
- name: Build on Rust ${{ matrix.toolchain }}
4240
run: cargo build --verbose --color always
4341
- name: Check formatting
@@ -49,8 +47,6 @@ jobs:
4947
- name: Test on Rust ${{ matrix.toolchain }}
5048
run: |
5149
cargo test
52-
RUSTFLAGS="--cfg lsps1" cargo test
5350
- name: Test on Rust ${{ matrix.toolchain }} with no-std support
5451
run: |
5552
cargo test --no-default-features --features no-std
56-
RUSTFLAGS="--cfg lsps1" cargo test --no-default-features --features no-std

src/events.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
//! [`LiquidityManager::get_and_clear_pending_events`]: crate::LiquidityManager::get_and_clear_pending_events
1717
1818
use crate::lsps0;
19-
#[cfg(lsps1)]
2019
use crate::lsps1;
2120
use crate::lsps2;
2221
use crate::prelude::{Vec, VecDeque};
@@ -98,10 +97,8 @@ pub enum Event {
9897
/// An LSPS0 client event.
9998
LSPS0Client(lsps0::event::LSPS0ClientEvent),
10099
/// An LSPS1 (Channel Request) client event.
101-
#[cfg(lsps1)]
102100
LSPS1Client(lsps1::event::LSPS1ClientEvent),
103101
/// An LSPS1 (Channel Request) server event.
104-
#[cfg(lsps1)]
105102
LSPS1Service(lsps1::event::LSPS1ServiceEvent),
106103
/// An LSPS2 (JIT Channel) client event.
107104
LSPS2Client(lsps2::event::LSPS2ClientEvent),

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ mod prelude {
4141

4242
pub mod events;
4343
pub mod lsps0;
44-
#[cfg(lsps1)]
4544
// TODO: disallow warnings once the implementation is finished
4645
#[allow(warnings)]
4746
pub mod lsps1;

src/lsps0/msgs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ impl TryFrom<LSPSMessage> for LSPS0Message {
7676
match message {
7777
LSPSMessage::Invalid(_) => Err(()),
7878
LSPSMessage::LSPS0(message) => Ok(message),
79-
#[cfg(lsps1)]
8079
LSPSMessage::LSPS1(_) => Err(()),
8180
LSPSMessage::LSPS2(_) => Err(()),
8281
}

src/lsps0/ser.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::lsps0::msgs::{
77
LSPS0_LISTPROTOCOLS_METHOD_NAME,
88
};
99

10-
#[cfg(lsps1)]
1110
use crate::lsps1::msgs::{
1211
LSPS1Message, LSPS1Request, LSPS1Response, LSPS1_CREATE_ORDER_METHOD_NAME,
1312
LSPS1_GET_INFO_METHOD_NAME, LSPS1_GET_ORDER_METHOD_NAME,
@@ -47,11 +46,8 @@ pub(crate) const _LSPS0_CLIENT_REJECTED_ERROR_CODE: i32 = 001;
4746
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
4847
pub(crate) enum LSPSMethod {
4948
LSPS0ListProtocols,
50-
#[cfg(lsps1)]
5149
LSPS1GetInfo,
52-
#[cfg(lsps1)]
5350
LSPS1GetOrder,
54-
#[cfg(lsps1)]
5551
LSPS1CreateOrder,
5652
LSPS2GetInfo,
5753
LSPS2Buy,
@@ -62,11 +58,8 @@ impl FromStr for LSPSMethod {
6258
fn from_str(s: &str) -> Result<Self, Self::Err> {
6359
match s {
6460
LSPS0_LISTPROTOCOLS_METHOD_NAME => Ok(Self::LSPS0ListProtocols),
65-
#[cfg(lsps1)]
6661
LSPS1_GET_INFO_METHOD_NAME => Ok(Self::LSPS1GetInfo),
67-
#[cfg(lsps1)]
6862
LSPS1_CREATE_ORDER_METHOD_NAME => Ok(Self::LSPS1CreateOrder),
69-
#[cfg(lsps1)]
7063
LSPS1_GET_ORDER_METHOD_NAME => Ok(Self::LSPS1GetOrder),
7164
LSPS2_GET_INFO_METHOD_NAME => Ok(Self::LSPS2GetInfo),
7265
LSPS2_BUY_METHOD_NAME => Ok(Self::LSPS2Buy),
@@ -79,11 +72,8 @@ impl Display for LSPSMethod {
7972
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8073
let s = match self {
8174
Self::LSPS0ListProtocols => LSPS0_LISTPROTOCOLS_METHOD_NAME,
82-
#[cfg(lsps1)]
8375
Self::LSPS1GetInfo => LSPS1_GET_INFO_METHOD_NAME,
84-
#[cfg(lsps1)]
8576
Self::LSPS1CreateOrder => LSPS1_CREATE_ORDER_METHOD_NAME,
86-
#[cfg(lsps1)]
8777
Self::LSPS1GetOrder => LSPS1_GET_ORDER_METHOD_NAME,
8878
Self::LSPS2GetInfo => LSPS2_GET_INFO_METHOD_NAME,
8979
Self::LSPS2Buy => LSPS2_BUY_METHOD_NAME,
@@ -100,7 +90,6 @@ impl From<&LSPS0Request> for LSPSMethod {
10090
}
10191
}
10292

103-
#[cfg(lsps1)]
10493
impl From<&LSPS1Request> for LSPSMethod {
10594
fn from(value: &LSPS1Request) -> Self {
10695
match value {
@@ -216,7 +205,6 @@ pub enum LSPSMessage {
216205
/// An LSPS0 message.
217206
LSPS0(LSPS0Message),
218207
/// An LSPS1 message.
219-
#[cfg(lsps1)]
220208
LSPS1(LSPS1Message),
221209
/// An LSPS2 message.
222210
LSPS2(LSPS2Message),
@@ -241,7 +229,6 @@ impl LSPSMessage {
241229
LSPSMessage::LSPS0(LSPS0Message::Request(request_id, request)) => {
242230
Some((RequestId(request_id.0.clone()), request.into()))
243231
},
244-
#[cfg(lsps1)]
245232
LSPSMessage::LSPS1(LSPS1Message::Request(request_id, request)) => {
246233
Some((RequestId(request_id.0.clone()), request.into()))
247234
},
@@ -287,7 +274,6 @@ impl Serialize for LSPSMessage {
287274
},
288275
}
289276
},
290-
#[cfg(lsps1)]
291277
LSPSMessage::LSPS1(LSPS1Message::Request(request_id, request)) => {
292278
jsonrpc_object.serialize_field(JSONRPC_ID_FIELD_KEY, &request_id.0)?;
293279
jsonrpc_object
@@ -305,7 +291,6 @@ impl Serialize for LSPSMessage {
305291
},
306292
}
307293
},
308-
#[cfg(lsps1)]
309294
LSPSMessage::LSPS1(LSPS1Message::Response(request_id, response)) => {
310295
jsonrpc_object.serialize_field(JSONRPC_ID_FIELD_KEY, &request_id.0)?;
311296

@@ -442,7 +427,6 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
442427
id,
443428
LSPS0Request::ListProtocols(ListProtocolsRequest {}),
444429
))),
445-
#[cfg(lsps1)]
446430
LSPSMethod::LSPS1GetInfo => {
447431
let request = serde_json::from_value(params.unwrap_or(json!({})))
448432
.map_err(de::Error::custom)?;
@@ -451,7 +435,6 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
451435
LSPS1Request::GetInfo(request),
452436
)))
453437
},
454-
#[cfg(lsps1)]
455438
LSPSMethod::LSPS1CreateOrder => {
456439
let request = serde_json::from_value(params.unwrap_or(json!({})))
457440
.map_err(de::Error::custom)?;
@@ -460,7 +443,6 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
460443
LSPS1Request::CreateOrder(request),
461444
)))
462445
},
463-
#[cfg(lsps1)]
464446
LSPSMethod::LSPS1GetOrder => {
465447
let request = serde_json::from_value(params.unwrap_or(json!({})))
466448
.map_err(de::Error::custom)?;
@@ -502,7 +484,6 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
502484
Err(de::Error::custom("Received invalid JSON-RPC object: one of method, result, or error required"))
503485
}
504486
},
505-
#[cfg(lsps1)]
506487
LSPSMethod::LSPS1GetInfo => {
507488
if let Some(error) = error {
508489
Ok(LSPSMessage::LSPS1(LSPS1Message::Response(
@@ -520,7 +501,6 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
520501
Err(de::Error::custom("Received invalid JSON-RPC object: one of method, result, or error required"))
521502
}
522503
},
523-
#[cfg(lsps1)]
524504
LSPSMethod::LSPS1CreateOrder => {
525505
if let Some(error) = error {
526506
Ok(LSPSMessage::LSPS1(LSPS1Message::Response(
@@ -538,7 +518,6 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
538518
Err(de::Error::custom("Received invalid JSON-RPC object: one of method, result, or error required"))
539519
}
540520
},
541-
#[cfg(lsps1)]
542521
LSPSMethod::LSPS1GetOrder => {
543522
if let Some(error) = error {
544523
Ok(LSPSMessage::LSPS1(LSPS1Message::Response(
@@ -654,7 +633,6 @@ pub(crate) mod string_amount_option {
654633
}
655634
}
656635

657-
#[cfg(lsps1)]
658636
pub(crate) mod u32_fee_rate {
659637
use bitcoin::FeeRate;
660638
use serde::{Deserialize, Deserializer, Serializer};

src/manager.rs

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ use crate::lsps0::ser::{
99
use crate::lsps0::service::LSPS0ServiceHandler;
1010
use crate::message_queue::MessageQueue;
1111

12-
#[cfg(lsps1)]
1312
use crate::lsps1::client::{LSPS1ClientConfig, LSPS1ClientHandler};
14-
#[cfg(lsps1)]
1513
use crate::lsps1::msgs::LSPS1Message;
16-
#[cfg(lsps1)]
1714
use crate::lsps1::service::{LSPS1ServiceConfig, LSPS1ServiceHandler};
1815

1916
use crate::lsps2::client::{LSPS2ClientConfig, LSPS2ClientHandler};
@@ -44,7 +41,6 @@ const LSPS_FEATURE_BIT: usize = 729;
4441
/// to provide liquidity services to clients.
4542
pub struct LiquidityServiceConfig {
4643
/// Optional server-side configuration for LSPS1 channel requests.
47-
#[cfg(lsps1)]
4844
pub lsps1_service_config: Option<LSPS1ServiceConfig>,
4945
/// Optional server-side configuration for JIT channels
5046
/// should you want to support them.
@@ -60,7 +56,6 @@ pub struct LiquidityServiceConfig {
6056
/// to access liquidity services from a provider.
6157
pub struct LiquidityClientConfig {
6258
/// Optional client-side configuration for LSPS1 channel requests.
63-
#[cfg(lsps1)]
6459
pub lsps1_client_config: Option<LSPS1ClientConfig>,
6560
/// Optional client-side configuration for JIT channels.
6661
pub lsps2_client_config: Option<LSPS2ClientConfig>,
@@ -97,9 +92,7 @@ where
9792
ignored_peers: RwLock<HashSet<PublicKey>>,
9893
lsps0_client_handler: LSPS0ClientHandler<ES>,
9994
lsps0_service_handler: Option<LSPS0ServiceHandler>,
100-
#[cfg(lsps1)]
10195
lsps1_service_handler: Option<LSPS1ServiceHandler<ES, CM, C>>,
102-
#[cfg(lsps1)]
10396
lsps1_client_handler: Option<LSPS1ClientHandler<ES, CM, C>>,
10497
lsps2_service_handler: Option<LSPS2ServiceHandler<CM>>,
10598
lsps2_client_handler: Option<LSPS2ClientHandler<ES>>,
@@ -162,7 +155,6 @@ where {
162155
})
163156
});
164157

165-
#[cfg(lsps1)]
166158
let lsps1_client_handler = client_config.as_ref().and_then(|config| {
167159
config.lsps1_client_config.as_ref().map(|config| {
168160
LSPS1ClientHandler::new(
@@ -176,7 +168,6 @@ where {
176168
})
177169
});
178170

179-
#[cfg(lsps1)]
180171
let lsps1_service_handler = service_config.as_ref().and_then(|config| {
181172
config.lsps1_service_config.as_ref().map(|config| {
182173
LSPS1ServiceHandler::new(
@@ -197,9 +188,7 @@ where {
197188
ignored_peers,
198189
lsps0_client_handler,
199190
lsps0_service_handler,
200-
#[cfg(lsps1)]
201191
lsps1_client_handler,
202-
#[cfg(lsps1)]
203192
lsps1_service_handler,
204193
lsps2_client_handler,
205194
lsps2_service_handler,
@@ -221,13 +210,11 @@ where {
221210
}
222211

223212
/// Returns a reference to the LSPS1 client-side handler.
224-
#[cfg(lsps1)]
225213
pub fn lsps1_client_handler(&self) -> Option<&LSPS1ClientHandler<ES, CM, C>> {
226214
self.lsps1_client_handler.as_ref()
227215
}
228216

229217
/// Returns a reference to the LSPS1 server-side handler.
230-
#[cfg(lsps1)]
231218
pub fn lsps1_service_handler(&self) -> Option<&LSPS1ServiceHandler<ES, CM, C>> {
232219
self.lsps1_service_handler.as_ref()
233220
}
@@ -411,23 +398,25 @@ where {
411398
},
412399
}
413400
},
414-
#[cfg(lsps1)]
415-
LSPSMessage::LSPS1(msg @ LSPS1Message::Response(..)) => match &self.lsps1_client_handler {
416-
Some(lsps1_client_handler) => {
417-
lsps1_client_handler.handle_message(msg, sender_node_id)?;
418-
},
419-
None => {
420-
return Err(LightningError { err: format!("Received LSPS1 response message without LSPS1 client handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)});
421-
},
401+
LSPSMessage::LSPS1(msg @ LSPS1Message::Response(..)) => {
402+
match &self.lsps1_client_handler {
403+
Some(lsps1_client_handler) => {
404+
lsps1_client_handler.handle_message(msg, sender_node_id)?;
405+
},
406+
None => {
407+
return Err(LightningError { err: format!("Received LSPS1 response message without LSPS1 client handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)});
408+
},
409+
}
422410
},
423-
#[cfg(lsps1)]
424-
LSPSMessage::LSPS1(msg @ LSPS1Message::Request(..)) => match &self.lsps1_service_handler {
425-
Some(lsps1_service_handler) => {
426-
lsps1_service_handler.handle_message(msg, sender_node_id)?;
427-
},
428-
None => {
429-
return Err(LightningError { err: format!("Received LSPS1 request message without LSPS1 service handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)});
430-
},
411+
LSPSMessage::LSPS1(msg @ LSPS1Message::Request(..)) => {
412+
match &self.lsps1_service_handler {
413+
Some(lsps1_service_handler) => {
414+
lsps1_service_handler.handle_message(msg, sender_node_id)?;
415+
},
416+
None => {
417+
return Err(LightningError { err: format!("Received LSPS1 request message without LSPS1 service handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)});
418+
},
419+
}
431420
},
432421
LSPSMessage::LSPS2(msg @ LSPS2Message::Response(..)) => {
433422
match &self.lsps2_client_handler {

tests/lsps2_integration_tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,13 @@ fn invoice_generation_flow() {
8585
let promise_secret = [42; 32];
8686
let lsps2_service_config = LSPS2ServiceConfig { promise_secret };
8787
let service_config = LiquidityServiceConfig {
88-
#[cfg(lsps1)]
8988
lsps1_service_config: None,
9089
lsps2_service_config: Some(lsps2_service_config),
9190
advertise_service: true,
9291
};
9392

9493
let lsps2_client_config = LSPS2ClientConfig::default();
9594
let client_config = LiquidityClientConfig {
96-
#[cfg(lsps1)]
9795
lsps1_client_config: None,
9896
lsps2_client_config: Some(lsps2_client_config),
9997
};

0 commit comments

Comments
 (0)