@@ -23,7 +23,8 @@ use crate::io::{
2323 self , PAYMENT_INFO_PERSISTENCE_PRIMARY_NAMESPACE , PAYMENT_INFO_PERSISTENCE_SECONDARY_NAMESPACE ,
2424} ;
2525use crate :: liquidity:: {
26- LSPS1ClientConfig , LSPS2ClientConfig , LSPS2ServiceConfig , LiquiditySourceBuilder ,
26+ LSPS1ClientConfig , LSPS2ClientConfig , LSPS2ServiceConfig , LSPS5ClientConfig ,
27+ LSPS5ServiceConfig , LiquiditySourceBuilder ,
2728} ;
2829use crate :: logger:: { log_error, LdkLogger , LogLevel , LogWriter , Logger } ;
2930use crate :: message_handler:: NodeCustomMessageHandler ;
@@ -125,6 +126,10 @@ struct LiquiditySourceConfig {
125126 lsps2_client : Option < LSPS2ClientConfig > ,
126127 // Act as an LSPS2 service.
127128 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 > ,
128133}
129134
130135#[ derive( Clone ) ]
@@ -738,6 +743,27 @@ impl NodeBuilder {
738743 kv_store,
739744 )
740745 }
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+ }
741767}
742768
743769/// A builder for an [`Node`] instance, allowing to set some configuration and module choices from
@@ -928,6 +954,20 @@ impl ArcedNodeBuilder {
928954 self . inner . write ( ) . unwrap ( ) . set_liquidity_provider_lsps2 ( service_config) ;
929955 }
930956
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+
931971 /// Sets the used storage directory path.
932972 pub fn set_storage_dir_path ( & self , storage_dir_path : String ) {
933973 self . inner . write ( ) . unwrap ( ) . set_storage_dir_path ( storage_dir_path) ;
@@ -1542,6 +1582,13 @@ fn build_with_store_internal(
15421582 liquidity_source_builder. lsps2_service ( promise_secret, config. clone ( ) )
15431583 } ) ;
15441584
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+
15451592 let liquidity_source = Arc :: new ( liquidity_source_builder. build ( ) ) ;
15461593 let custom_message_handler =
15471594 Arc :: new ( NodeCustomMessageHandler :: new_liquidity ( Arc :: clone ( & liquidity_source) ) ) ;
0 commit comments