@@ -18,7 +18,7 @@ use crate::gossip::GossipSource;
18
18
use crate :: io:: sqlite_store:: SqliteStore ;
19
19
use crate :: io:: utils:: { read_node_metrics, write_node_metrics} ;
20
20
use crate :: io:: vss_store:: VssStore ;
21
- use crate :: liquidity:: LiquiditySource ;
21
+ use crate :: liquidity:: LiquiditySourceBuilder ;
22
22
use crate :: logger:: { log_error, log_info, LdkLogger , LogLevel , LogWriter , Logger } ;
23
23
use crate :: message_handler:: NodeCustomMessageHandler ;
24
24
use crate :: payment:: store:: PaymentStore ;
@@ -54,9 +54,6 @@ use lightning::util::sweep::OutputSweeper;
54
54
55
55
use lightning_persister:: fs_store:: FilesystemStore ;
56
56
57
- use lightning_liquidity:: lsps2:: client:: LSPS2ClientConfig ;
58
- use lightning_liquidity:: { LiquidityClientConfig , LiquidityManager } ;
59
-
60
57
use bdk_wallet:: template:: Bip84 ;
61
58
use bdk_wallet:: KeychainKind ;
62
59
use bdk_wallet:: Wallet as BdkWallet ;
@@ -99,13 +96,15 @@ enum GossipSourceConfig {
99
96
100
97
#[ derive( Debug , Clone ) ]
101
98
struct LiquiditySourceConfig {
102
- // LSPS2 service's (address, node_id, token)
103
- lsps2_service : Option < ( SocketAddress , PublicKey , Option < String > ) > ,
99
+ // LSPS1 service's (node_id, address, token)
100
+ lsps1_service : Option < ( PublicKey , SocketAddress , Option < String > ) > ,
101
+ // LSPS2 service's (node_id, address, token)
102
+ lsps2_service : Option < ( PublicKey , SocketAddress , Option < String > ) > ,
104
103
}
105
104
106
105
impl Default for LiquiditySourceConfig {
107
106
fn default ( ) -> Self {
108
- Self { lsps2_service : None }
107
+ Self { lsps1_service : None , lsps2_service : None }
109
108
}
110
109
}
111
110
@@ -304,22 +303,43 @@ impl NodeBuilder {
304
303
self
305
304
}
306
305
307
- /// Configures the [`Node`] instance to source its inbound liquidity from the given
308
- /// [LSPS2](https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md)
309
- /// service.
306
+ /// Configures the [`Node`] instance to source inbound liquidity from the given
307
+ /// [bLIP-51 / LSPS1] service.
308
+ ///
309
+ /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
310
+ ///
311
+ /// The given `token` will be used by the LSP to authenticate the user.
312
+ ///
313
+ /// [bLIP-51 / LSPS1]: https://github.com/lightning/blips/blob/master/blip-0051.md
314
+ pub fn set_liquidity_source_lsps1 (
315
+ & mut self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
316
+ ) -> & mut Self {
317
+ // Mark the LSP as trusted for 0conf
318
+ self . config . trusted_peers_0conf . push ( node_id. clone ( ) ) ;
319
+
320
+ let liquidity_source_config =
321
+ self . liquidity_source_config . get_or_insert ( LiquiditySourceConfig :: default ( ) ) ;
322
+ liquidity_source_config. lsps1_service = Some ( ( node_id, address, token) ) ;
323
+ self
324
+ }
325
+
326
+ /// Configures the [`Node`] instance to source just-in-time inbound liquidity from the given
327
+ /// [bLIP-52 / LSPS2] service.
310
328
///
311
329
/// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
312
330
///
313
331
/// The given `token` will be used by the LSP to authenticate the user.
332
+ ///
333
+ /// [bLIP-52 / LSPS2]: https://github.com/lightning/blips/blob/master/blip-0052.md
314
334
pub fn set_liquidity_source_lsps2 (
315
- & mut self , address : SocketAddress , node_id : PublicKey , token : Option < String > ,
335
+ & mut self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
316
336
) -> & mut Self {
317
337
// Mark the LSP as trusted for 0conf
318
338
self . config . trusted_peers_0conf . push ( node_id. clone ( ) ) ;
319
339
320
340
let liquidity_source_config =
321
341
self . liquidity_source_config . get_or_insert ( LiquiditySourceConfig :: default ( ) ) ;
322
- liquidity_source_config. lsps2_service = Some ( ( address , node_id , token) ) ;
342
+ liquidity_source_config. lsps2_service = Some ( ( node_id , address , token) ) ;
323
343
self
324
344
}
325
345
@@ -643,17 +663,32 @@ impl ArcedNodeBuilder {
643
663
self . inner . write ( ) . unwrap ( ) . set_gossip_source_rgs ( rgs_server_url) ;
644
664
}
645
665
646
- /// Configures the [`Node`] instance to source its inbound liquidity from the given
647
- /// [LSPS2](https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md)
648
- /// service.
666
+ /// Configures the [`Node`] instance to source inbound liquidity from the given
667
+ /// [bLIP-51 / LSPS1] service.
649
668
///
650
669
/// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
651
670
///
652
671
/// The given `token` will be used by the LSP to authenticate the user.
672
+ ///
673
+ /// [bLIP-51 / LSPS1]: https://github.com/lightning/blips/blob/master/blip-0051.md
674
+ pub fn set_liquidity_source_lsps1 (
675
+ & self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
676
+ ) {
677
+ self . inner . write ( ) . unwrap ( ) . set_liquidity_source_lsps1 ( node_id, address, token) ;
678
+ }
679
+
680
+ /// Configures the [`Node`] instance to source just-in-time inbound liquidity from the given
681
+ /// [bLIP-52 / LSPS2] service.
682
+ ///
683
+ /// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
684
+ ///
685
+ /// The given `token` will be used by the LSP to authenticate the user.
686
+ ///
687
+ /// [bLIP-52 / LSPS2]: https://github.com/lightning/blips/blob/master/blip-0052.md
653
688
pub fn set_liquidity_source_lsps2 (
654
- & self , address : SocketAddress , node_id : PublicKey , token : Option < String > ,
689
+ & self , node_id : PublicKey , address : SocketAddress , token : Option < String > ,
655
690
) {
656
- self . inner . write ( ) . unwrap ( ) . set_liquidity_source_lsps2 ( address , node_id , token) ;
691
+ self . inner . write ( ) . unwrap ( ) . set_liquidity_source_lsps2 ( node_id , address , token) ;
657
692
}
658
693
659
694
/// Sets the used storage directory path.
@@ -1136,30 +1171,24 @@ fn build_with_store_internal(
1136
1171
} ,
1137
1172
} ;
1138
1173
1139
- let liquidity_source = liquidity_source_config. as_ref ( ) . and_then ( |lsc| {
1140
- lsc. lsps2_service . as_ref ( ) . map ( |( address, node_id, token) | {
1141
- let lsps2_client_config = Some ( LSPS2ClientConfig { } ) ;
1142
- let liquidity_client_config =
1143
- Some ( LiquidityClientConfig { lsps1_client_config : None , lsps2_client_config } ) ;
1144
- let liquidity_manager = Arc :: new ( LiquidityManager :: new (
1145
- Arc :: clone ( & keys_manager) ,
1146
- Arc :: clone ( & channel_manager) ,
1147
- Some ( Arc :: clone ( & chain_source) ) ,
1148
- None ,
1149
- None ,
1150
- liquidity_client_config,
1151
- ) ) ;
1152
- Arc :: new ( LiquiditySource :: new_lsps2 (
1153
- address. clone ( ) ,
1154
- * node_id,
1155
- token. clone ( ) ,
1156
- Arc :: clone ( & channel_manager) ,
1157
- Arc :: clone ( & keys_manager) ,
1158
- liquidity_manager,
1159
- Arc :: clone ( & config) ,
1160
- Arc :: clone ( & logger) ,
1161
- ) )
1162
- } )
1174
+ let liquidity_source = liquidity_source_config. as_ref ( ) . map ( |lsc| {
1175
+ let mut liquidity_source_builder = LiquiditySourceBuilder :: new (
1176
+ Arc :: clone ( & channel_manager) ,
1177
+ Arc :: clone ( & keys_manager) ,
1178
+ Arc :: clone ( & chain_source) ,
1179
+ Arc :: clone ( & config) ,
1180
+ Arc :: clone ( & logger) ,
1181
+ ) ;
1182
+
1183
+ lsc. lsps1_service . as_ref ( ) . map ( |( node_id, address, token) | {
1184
+ liquidity_source_builder. lsps1_service ( * node_id, address. clone ( ) , token. clone ( ) )
1185
+ } ) ;
1186
+
1187
+ lsc. lsps2_service . as_ref ( ) . map ( |( node_id, address, token) | {
1188
+ liquidity_source_builder. lsps2_service ( * node_id, address. clone ( ) , token. clone ( ) )
1189
+ } ) ;
1190
+
1191
+ Arc :: new ( liquidity_source_builder. build ( ) )
1163
1192
} ) ;
1164
1193
1165
1194
let custom_message_handler = if let Some ( liquidity_source) = liquidity_source. as_ref ( ) {
0 commit comments