@@ -23,7 +23,8 @@ use crate::io::{
23
23
self , PAYMENT_INFO_PERSISTENCE_PRIMARY_NAMESPACE , PAYMENT_INFO_PERSISTENCE_SECONDARY_NAMESPACE ,
24
24
} ;
25
25
use crate :: liquidity:: {
26
- LSPS1ClientConfig , LSPS2ClientConfig , LSPS2ServiceConfig , LiquiditySourceBuilder ,
26
+ LSPS1ClientConfig , LSPS2ClientConfig , LSPS2ServiceConfig , LSPS5ClientConfig ,
27
+ LSPS5ServiceConfig , LiquiditySourceBuilder ,
27
28
} ;
28
29
use crate :: logger:: { log_error, LdkLogger , LogLevel , LogWriter , Logger } ;
29
30
use crate :: message_handler:: NodeCustomMessageHandler ;
@@ -125,6 +126,10 @@ struct LiquiditySourceConfig {
125
126
lsps2_client : Option < LSPS2ClientConfig > ,
126
127
// Act as an LSPS2 service.
127
128
lsps2_service : Option < LSPS2ServiceConfig > ,
129
+ /// Act as an LSPS5 client connecting to the given service.
130
+ lsps5_client : Option < LSPS5ClientConfig > ,
131
+ // Act as an LSPS5 service.
132
+ lsps5_service : Option < LSPS5ServiceConfig > ,
128
133
}
129
134
130
135
#[ derive( Clone ) ]
@@ -738,6 +743,27 @@ impl NodeBuilder {
738
743
kv_store,
739
744
)
740
745
}
746
+
747
+ /// Configures the [`Node`] instance to source inbound liquidity from the given
748
+ pub fn set_liquidity_source_lsps5 (
749
+ & mut self , node_id : PublicKey , address : SocketAddress ,
750
+ ) -> & mut Self {
751
+ let liquidity_source_config =
752
+ self . liquidity_source_config . get_or_insert ( LiquiditySourceConfig :: default ( ) ) ;
753
+ let lsps5_client_config = LSPS5ClientConfig { node_id, address } ;
754
+ liquidity_source_config. lsps5_client = Some ( lsps5_client_config) ;
755
+ self
756
+ }
757
+
758
+ /// Configures the [`Node`] instance to provide an LSPS5 service
759
+ pub fn set_liquidity_provider_lsps5 (
760
+ & mut self , service_config : LSPS5ServiceConfig ,
761
+ ) -> & mut Self {
762
+ let liquidity_source_config =
763
+ self . liquidity_source_config . get_or_insert ( LiquiditySourceConfig :: default ( ) ) ;
764
+ liquidity_source_config. lsps5_service = Some ( service_config) ;
765
+ self
766
+ }
741
767
}
742
768
743
769
/// A builder for an [`Node`] instance, allowing to set some configuration and module choices from
@@ -928,6 +954,20 @@ impl ArcedNodeBuilder {
928
954
self . inner . write ( ) . unwrap ( ) . set_liquidity_provider_lsps2 ( service_config) ;
929
955
}
930
956
957
+ /// Configures the [`Node`] instance to source inbound liquidity from the given [LSPS5] LSP.
958
+ ///
959
+ /// [LSPS5]: https://github.com/lightning/blips/blob/master/blip-0055.md
960
+ pub fn set_liquidity_source_lsps5 ( & self , node_id : PublicKey , address : SocketAddress ) {
961
+ self . inner . write ( ) . unwrap ( ) . set_liquidity_source_lsps5 ( node_id, address) ;
962
+ }
963
+
964
+ /// Configures the [`Node`] instance to provide an LSPS5 service.
965
+ ///
966
+ /// [LSPS5]: https://github.com/lightning/blips/blob/master/blip-0055.md
967
+ pub fn set_liquidity_provider_lsps5 ( & self , service_config : LSPS5ServiceConfig ) {
968
+ self . inner . write ( ) . unwrap ( ) . set_liquidity_provider_lsps5 ( service_config) ;
969
+ }
970
+
931
971
/// Sets the used storage directory path.
932
972
pub fn set_storage_dir_path ( & self , storage_dir_path : String ) {
933
973
self . inner . write ( ) . unwrap ( ) . set_storage_dir_path ( storage_dir_path) ;
@@ -1542,6 +1582,13 @@ fn build_with_store_internal(
1542
1582
liquidity_source_builder. lsps2_service ( promise_secret, config. clone ( ) )
1543
1583
} ) ;
1544
1584
1585
+ lsc. lsps5_client . as_ref ( ) . map ( |config| {
1586
+ liquidity_source_builder. lsps5_client ( config. node_id , config. address . clone ( ) )
1587
+ } ) ;
1588
+ lsc. lsps5_service
1589
+ . as_ref ( )
1590
+ . map ( |config| liquidity_source_builder. lsps5_service ( config. clone ( ) ) ) ;
1591
+
1545
1592
let liquidity_source = Arc :: new ( liquidity_source_builder. build ( ) ) ;
1546
1593
let custom_message_handler =
1547
1594
Arc :: new ( NodeCustomMessageHandler :: new_liquidity ( Arc :: clone ( & liquidity_source) ) ) ;
0 commit comments