@@ -18,7 +18,7 @@ use crate::gossip::GossipSource;
1818use crate :: io:: sqlite_store:: SqliteStore ;
1919use crate :: io:: utils:: { read_node_metrics, write_node_metrics} ;
2020use crate :: io:: vss_store:: VssStore ;
21- use crate :: liquidity:: LiquiditySource ;
21+ use crate :: liquidity:: LiquiditySourceBuilder ;
2222use crate :: logger:: { log_error, log_info, LdkLogger , LogLevel , LogWriter , Logger } ;
2323use crate :: message_handler:: NodeCustomMessageHandler ;
2424use crate :: payment:: store:: PaymentStore ;
@@ -54,9 +54,6 @@ use lightning::util::sweep::OutputSweeper;
5454
5555use lightning_persister:: fs_store:: FilesystemStore ;
5656
57- use lightning_liquidity:: lsps2:: client:: LSPS2ClientConfig ;
58- use lightning_liquidity:: { LiquidityClientConfig , LiquidityManager } ;
59-
6057use bdk_wallet:: template:: Bip84 ;
6158use bdk_wallet:: KeychainKind ;
6259use bdk_wallet:: Wallet as BdkWallet ;
@@ -99,13 +96,15 @@ enum GossipSourceConfig {
9996
10097#[ derive( Debug , Clone ) ]
10198struct LiquiditySourceConfig {
99+ // LSPS1 service's (node_id, address, token)
100+ lsps1_service : Option < ( PublicKey , SocketAddress , Option < String > ) > ,
102101 // LSPS2 service's (node_id, address, token)
103102 lsps2_service : Option < ( PublicKey , SocketAddress , Option < String > ) > ,
104103}
105104
106105impl Default for LiquiditySourceConfig {
107106 fn default ( ) -> Self {
108- Self { lsps2_service : None }
107+ Self { lsps1_service : None , lsps2_service : None }
109108 }
110109}
111110
@@ -322,13 +321,34 @@ impl NodeBuilder {
322321 self
323322 }
324323
325- /// Configures the [`Node`] instance to source its inbound liquidity from the given
326- /// [LSPS2](https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md)
327- /// service.
324+ /// Configures the [`Node`] instance to source inbound liquidity from the given
325+ /// [bLIP-51 / LSPS1] service.
328326 ///
329327 /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
330328 ///
331329 /// The given `token` will be used by the LSP to authenticate the user.
330+ ///
331+ /// [bLIP-51 / LSPS1]: https://github.com/lightning/blips/blob/master/blip-0051.md
332+ pub fn set_liquidity_source_lsps1 (
333+ & mut self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
334+ ) -> & mut Self {
335+ // Mark the LSP as trusted for 0conf
336+ self . config . trusted_peers_0conf . push ( node_id. clone ( ) ) ;
337+
338+ let liquidity_source_config =
339+ self . liquidity_source_config . get_or_insert ( LiquiditySourceConfig :: default ( ) ) ;
340+ liquidity_source_config. lsps1_service = Some ( ( node_id, address, token) ) ;
341+ self
342+ }
343+
344+ /// Configures the [`Node`] instance to source just-in-time inbound liquidity from the given
345+ /// [bLIP-52 / LSPS2] service.
346+ ///
347+ /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
348+ ///
349+ /// The given `token` will be used by the LSP to authenticate the user.
350+ ///
351+ /// [bLIP-52 / LSPS2]: https://github.com/lightning/blips/blob/master/blip-0052.md
332352 pub fn set_liquidity_source_lsps2 (
333353 & mut self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
334354 ) -> & mut Self {
@@ -654,13 +674,28 @@ impl ArcedNodeBuilder {
654674 self . inner . write ( ) . unwrap ( ) . set_gossip_source_rgs ( rgs_server_url) ;
655675 }
656676
657- /// Configures the [`Node`] instance to source its inbound liquidity from the given
658- /// [LSPS2](https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md)
659- /// service.
677+ /// Configures the [`Node`] instance to source inbound liquidity from the given
678+ /// [bLIP-51 / LSPS1] service.
660679 ///
661680 /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
662681 ///
663682 /// The given `token` will be used by the LSP to authenticate the user.
683+ ///
684+ /// [bLIP-51 / LSPS1]: https://github.com/lightning/blips/blob/master/blip-0051.md
685+ pub fn set_liquidity_source_lsps1 (
686+ & self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
687+ ) {
688+ self . inner . write ( ) . unwrap ( ) . set_liquidity_source_lsps1 ( node_id, address, token) ;
689+ }
690+
691+ /// Configures the [`Node`] instance to source just-in-time inbound liquidity from the given
692+ /// [bLIP-52 / LSPS2] service.
693+ ///
694+ /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
695+ ///
696+ /// The given `token` will be used by the LSP to authenticate the user.
697+ ///
698+ /// [bLIP-52 / LSPS2]: https://github.com/lightning/blips/blob/master/blip-0052.md
664699 pub fn set_liquidity_source_lsps2 (
665700 & self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
666701 ) {
@@ -1129,30 +1164,24 @@ fn build_with_store_internal(
11291164 } ,
11301165 } ;
11311166
1132- let liquidity_source = liquidity_source_config. as_ref ( ) . and_then ( |lsc| {
1167+ let liquidity_source = liquidity_source_config. as_ref ( ) . map ( |lsc| {
1168+ let mut liquidity_source_builder = LiquiditySourceBuilder :: new (
1169+ Arc :: clone ( & channel_manager) ,
1170+ Arc :: clone ( & keys_manager) ,
1171+ Arc :: clone ( & chain_source) ,
1172+ Arc :: clone ( & config) ,
1173+ Arc :: clone ( & logger) ,
1174+ ) ;
1175+
1176+ lsc. lsps1_service . as_ref ( ) . map ( |( node_id, address, token) | {
1177+ liquidity_source_builder. lsps1_service ( * node_id, address. clone ( ) , token. clone ( ) )
1178+ } ) ;
1179+
11331180 lsc. lsps2_service . as_ref ( ) . map ( |( node_id, address, token) | {
1134- let lsps2_client_config = Some ( LSPS2ClientConfig { } ) ;
1135- let liquidity_client_config =
1136- Some ( LiquidityClientConfig { lsps1_client_config : None , lsps2_client_config } ) ;
1137- let liquidity_manager = Arc :: new ( LiquidityManager :: new (
1138- Arc :: clone ( & keys_manager) ,
1139- Arc :: clone ( & channel_manager) ,
1140- Some ( Arc :: clone ( & chain_source) ) ,
1141- None ,
1142- None ,
1143- liquidity_client_config,
1144- ) ) ;
1145- Arc :: new ( LiquiditySource :: new_lsps2 (
1146- * node_id,
1147- address. clone ( ) ,
1148- token. clone ( ) ,
1149- Arc :: clone ( & channel_manager) ,
1150- Arc :: clone ( & keys_manager) ,
1151- liquidity_manager,
1152- Arc :: clone ( & config) ,
1153- Arc :: clone ( & logger) ,
1154- ) )
1155- } )
1181+ liquidity_source_builder. lsps2_service ( * node_id, address. clone ( ) , token. clone ( ) )
1182+ } ) ;
1183+
1184+ Arc :: new ( liquidity_source_builder. build ( ) )
11561185 } ) ;
11571186
11581187 let custom_message_handler = if let Some ( liquidity_source) = liquidity_source. as_ref ( ) {
0 commit comments