@@ -65,9 +65,7 @@ use crate::io::{
6565 PENDING_PAYMENT_INFO_PERSISTENCE_PRIMARY_NAMESPACE ,
6666 PENDING_PAYMENT_INFO_PERSISTENCE_SECONDARY_NAMESPACE ,
6767} ;
68- use crate :: liquidity:: {
69- LSPS1ClientConfig , LSPS2ClientConfig , LSPS2ServiceConfig , LiquiditySourceBuilder ,
70- } ;
68+ use crate :: liquidity:: { LSPS2ServiceConfig , LiquiditySourceBuilder , LspConfig } ;
7169use crate :: lnurl_auth:: LnurlAuth ;
7270use crate :: logger:: { log_error, LdkLogger , LogLevel , LogWriter , Logger } ;
7371use crate :: message_handler:: NodeCustomMessageHandler ;
@@ -120,10 +118,8 @@ struct PathfindingScoresSyncConfig {
120118
121119#[ derive( Debug , Clone , Default ) ]
122120struct LiquiditySourceConfig {
123- // Act as an LSPS1 client connecting to the given service.
124- lsps1_client : Option < LSPS1ClientConfig > ,
125- // Act as an LSPS2 client connecting to the given service.
126- lsps2_client : Option < LSPS2ClientConfig > ,
121+ // Acts for both LSPS1 and LSPS2 clients connecting to the given service.
122+ lsp_nodes : Vec < LspConfig > ,
127123 // Act as an LSPS2 service.
128124 lsps2_service : Option < LSPS2ServiceConfig > ,
129125}
@@ -435,45 +431,24 @@ impl NodeBuilder {
435431 self
436432 }
437433
438- /// Configures the [`Node`] instance to source inbound liquidity from the given
439- /// [bLIP-51 / LSPS1] service.
440- ///
441- /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
442- ///
443- /// The given `token` will be used by the LSP to authenticate the user.
444- ///
445- /// [bLIP-51 / LSPS1]: https://github.com/lightning/blips/blob/master/blip-0051.md
446- pub fn set_liquidity_source_lsps1 (
447- & mut self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
448- ) -> & mut Self {
449- // Mark the LSP as trusted for 0conf
450- self . config . trusted_peers_0conf . push ( node_id. clone ( ) ) ;
451-
452- let liquidity_source_config =
453- self . liquidity_source_config . get_or_insert ( LiquiditySourceConfig :: default ( ) ) ;
454- let lsps1_client_config = LSPS1ClientConfig { node_id, address, token } ;
455- liquidity_source_config. lsps1_client = Some ( lsps1_client_config) ;
456- self
457- }
458-
459- /// Configures the [`Node`] instance to source just-in-time inbound liquidity from the given
460- /// [bLIP-52 / LSPS2] service.
434+ /// Configures the [`Node`] instance to source inbound liquidity from the given LSP, without specifying
435+ /// the exact protocol used (e.g., LSPS1 or LSPS2).
461436 ///
462437 /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
463438 ///
464439 /// The given `token` will be used by the LSP to authenticate the user.
465- ///
466- /// [bLIP-52 / LSPS2]: https://github.com/lightning/blips/blob/master/blip-0052.md
467- pub fn set_liquidity_source_lsps2 (
440+ /// This method is useful when the user wants to connect to an LSP but does not want to be concerned with
441+ /// the specific protocol used for liquidity provision. The node will automatically detect and use the
442+ /// appropriate protocol supported by the LSP.
443+ pub fn add_liquidity_source (
468444 & mut self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
469445 ) -> & mut Self {
470446 // Mark the LSP as trusted for 0conf
471- self . config . trusted_peers_0conf . push ( node_id. clone ( ) ) ;
447+ self . config . trusted_peers_0conf . push ( node_id) ;
472448
473449 let liquidity_source_config =
474450 self . liquidity_source_config . get_or_insert ( LiquiditySourceConfig :: default ( ) ) ;
475- let lsps2_client_config = LSPS2ClientConfig { node_id, address, token } ;
476- liquidity_source_config. lsps2_client = Some ( lsps2_client_config) ;
451+ liquidity_source_config. lsp_nodes . push ( LspConfig { node_id, address, token } ) ;
477452 self
478453 }
479454
@@ -483,12 +458,12 @@ impl NodeBuilder {
483458 /// **Caution**: LSP service support is in **alpha** and is considered an experimental feature.
484459 ///
485460 /// [LSPS2]: https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md
486- pub fn set_liquidity_provider_lsps2 (
487- & mut self , service_config : LSPS2ServiceConfig ,
461+ pub fn enable_liquidity_provider (
462+ & mut self , lsps2_service_config : LSPS2ServiceConfig ,
488463 ) -> & mut Self {
489464 let liquidity_source_config =
490465 self . liquidity_source_config . get_or_insert ( LiquiditySourceConfig :: default ( ) ) ;
491- liquidity_source_config. lsps2_service = Some ( service_config ) ;
466+ liquidity_source_config. lsps2_service = Some ( lsps2_service_config ) ;
492467 self
493468 }
494469
@@ -956,32 +931,18 @@ impl ArcedNodeBuilder {
956931 self . inner . write ( ) . expect ( "lock" ) . set_pathfinding_scores_source ( url) ;
957932 }
958933
959- /// Configures the [`Node`] instance to source inbound liquidity from the given
960- /// [bLIP-51 / LSPS1] service.
934+ /// Configures the [`Node`] instance to source inbound liquidity from the given LSP.
961935 ///
962936 /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
963937 ///
964938 /// The given `token` will be used by the LSP to authenticate the user.
965- ///
966- /// [bLIP-51 / LSPS1]: https://github.com/lightning/blips/blob/master/blip-0051.md
967- pub fn set_liquidity_source_lsps1 (
939+ /// This method is useful when the user wants to connect to an LSP but does not want to be concerned with
940+ /// the specific protocol used for liquidity provision. The node will automatically detect and use the
941+ /// appropriate protocol supported by the LSP.
942+ pub fn add_liquidity_source (
968943 & self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
969944 ) {
970- self . inner . write ( ) . expect ( "lock" ) . set_liquidity_source_lsps1 ( node_id, address, token) ;
971- }
972-
973- /// Configures the [`Node`] instance to source just-in-time inbound liquidity from the given
974- /// [bLIP-52 / LSPS2] service.
975- ///
976- /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
977- ///
978- /// The given `token` will be used by the LSP to authenticate the user.
979- ///
980- /// [bLIP-52 / LSPS2]: https://github.com/lightning/blips/blob/master/blip-0052.md
981- pub fn set_liquidity_source_lsps2 (
982- & self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
983- ) {
984- self . inner . write ( ) . expect ( "lock" ) . set_liquidity_source_lsps2 ( node_id, address, token) ;
945+ self . inner . write ( ) . expect ( "lock" ) . add_liquidity_source ( node_id, address, token) ;
985946 }
986947
987948 /// Configures the [`Node`] instance to provide an [LSPS2] service, issuing just-in-time
@@ -990,8 +951,8 @@ impl ArcedNodeBuilder {
990951 /// **Caution**: LSP service support is in **alpha** and is considered an experimental feature.
991952 ///
992953 /// [LSPS2]: https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md
993- pub fn set_liquidity_provider_lsps2 ( & self , service_config : LSPS2ServiceConfig ) {
994- self . inner . write ( ) . expect ( "lock" ) . set_liquidity_provider_lsps2 ( service_config ) ;
954+ pub fn enable_liquidity_provider ( & self , lsps2_service_config : LSPS2ServiceConfig ) {
955+ self . inner . write ( ) . expect ( "lock" ) . enable_liquidity_provider ( lsps2_service_config ) ;
995956 }
996957
997958 /// Sets the used storage directory path.
@@ -1806,21 +1767,7 @@ fn build_with_store_internal(
18061767 Arc :: clone ( & logger) ,
18071768 ) ;
18081769
1809- lsc. lsps1_client . as_ref ( ) . map ( |config| {
1810- liquidity_source_builder. lsps1_client (
1811- config. node_id ,
1812- config. address . clone ( ) ,
1813- config. token . clone ( ) ,
1814- )
1815- } ) ;
1816-
1817- lsc. lsps2_client . as_ref ( ) . map ( |config| {
1818- liquidity_source_builder. lsps2_client (
1819- config. node_id ,
1820- config. address . clone ( ) ,
1821- config. token . clone ( ) ,
1822- )
1823- } ) ;
1770+ liquidity_source_builder. set_lsp_nodes ( lsc. lsp_nodes . clone ( ) ) ;
18241771
18251772 let promise_secret = {
18261773 let lsps_xpriv = derive_xprv (
@@ -1889,7 +1836,9 @@ fn build_with_store_internal(
18891836 }
18901837 } ) ) ;
18911838
1892- liquidity_source. as_ref ( ) . map ( |l| l. set_peer_manager ( Arc :: downgrade ( & peer_manager) ) ) ;
1839+ liquidity_source
1840+ . as_ref ( )
1841+ . map ( |l| l. lsps2_service ( ) . set_peer_manager ( Arc :: downgrade ( & peer_manager) ) ) ;
18931842
18941843 let connection_manager = Arc :: new ( ConnectionManager :: new (
18951844 Arc :: clone ( & peer_manager) ,
0 commit comments