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

Commit 339cb1b

Browse files
committed
Allow to disable service advertisement
The spec made advertising any LSPS service optional a while back, here we provide a way to configure it.
1 parent 71b9dd2 commit 339cb1b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/manager.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ pub struct LiquidityServiceConfig {
4545
/// Optional server-side configuration for JIT channels
4646
/// should you want to support them.
4747
pub lsps2_service_config: Option<LSPS2ServiceConfig>,
48+
/// Controls whether the liquidity service should be advertised via setting the feature bit in
49+
/// node announcment and the init message.
50+
pub advertise_service: bool,
4851
}
4952

5053
/// A client-side configuration for [`LiquidityManager`].
@@ -445,8 +448,12 @@ where
445448
fn provided_node_features(&self) -> NodeFeatures {
446449
let mut features = NodeFeatures::empty();
447450

448-
if self.service_config.is_some() {
449-
features.set_optional_custom_bit(LSPS_FEATURE_BIT).unwrap();
451+
let advertise_service = self.service_config.as_ref().map_or(false, |c| c.advertise_service);
452+
453+
if advertise_service {
454+
features
455+
.set_optional_custom_bit(LSPS_FEATURE_BIT)
456+
.expect("Failed to set LSPS feature bit");
450457
}
451458

452459
features
@@ -455,8 +462,11 @@ where
455462
fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
456463
let mut features = InitFeatures::empty();
457464

458-
if self.service_config.is_some() {
459-
features.set_optional_custom_bit(LSPS_FEATURE_BIT).unwrap();
465+
let advertise_service = self.service_config.as_ref().map_or(false, |c| c.advertise_service);
466+
if advertise_service {
467+
features
468+
.set_optional_custom_bit(LSPS_FEATURE_BIT)
469+
.expect("Failed to set LSPS feature bit");
460470
}
461471

462472
features

0 commit comments

Comments
 (0)