@@ -21,14 +21,16 @@ use lightning::routing::router::{RouteHint, RouteHintHop};
21
21
22
22
use lightning_invoice:: { Bolt11Invoice , Bolt11InvoiceDescription , InvoiceBuilder , RoutingFees } ;
23
23
24
- use lightning_liquidity:: events:: Event ;
25
- use lightning_liquidity:: lsps0:: ser:: RequestId ;
24
+ use lightning_liquidity:: events:: LiquidityEvent ;
25
+ use lightning_liquidity:: lsps0:: ser:: { LSPSDateTime , LSPSRequestId } ;
26
26
use lightning_liquidity:: lsps1:: client:: LSPS1ClientConfig as LdkLSPS1ClientConfig ;
27
27
use lightning_liquidity:: lsps1:: event:: LSPS1ClientEvent ;
28
- use lightning_liquidity:: lsps1:: msgs:: { ChannelInfo , LSPS1Options , OrderId , OrderParameters } ;
28
+ use lightning_liquidity:: lsps1:: msgs:: {
29
+ LSPS1ChannelInfo , LSPS1Options , LSPS1OrderId , LSPS1OrderParams ,
30
+ } ;
29
31
use lightning_liquidity:: lsps2:: client:: LSPS2ClientConfig as LdkLSPS2ClientConfig ;
30
32
use lightning_liquidity:: lsps2:: event:: { LSPS2ClientEvent , LSPS2ServiceEvent } ;
31
- use lightning_liquidity:: lsps2:: msgs:: { OpeningFeeParams , RawOpeningFeeParams } ;
33
+ use lightning_liquidity:: lsps2:: msgs:: { LSPS2OpeningFeeParams , LSPS2RawOpeningFeeParams } ;
32
34
use lightning_liquidity:: lsps2:: service:: LSPS2ServiceConfig as LdkLSPS2ServiceConfig ;
33
35
use lightning_liquidity:: lsps2:: utils:: compute_opening_fee;
34
36
use lightning_liquidity:: { LiquidityClientConfig , LiquidityServiceConfig } ;
@@ -40,7 +42,7 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1};
40
42
41
43
use tokio:: sync:: oneshot;
42
44
43
- use chrono:: { DateTime , Utc } ;
45
+ use chrono:: Utc ;
44
46
45
47
use rand:: Rng ;
46
48
@@ -61,10 +63,10 @@ struct LSPS1Client {
61
63
token : Option < String > ,
62
64
ldk_client_config : LdkLSPS1ClientConfig ,
63
65
pending_opening_params_requests :
64
- Mutex < HashMap < RequestId , oneshot:: Sender < LSPS1OpeningParamsResponse > > > ,
65
- pending_create_order_requests : Mutex < HashMap < RequestId , oneshot:: Sender < LSPS1OrderStatus > > > ,
66
+ Mutex < HashMap < LSPSRequestId , oneshot:: Sender < LSPS1OpeningParamsResponse > > > ,
67
+ pending_create_order_requests : Mutex < HashMap < LSPSRequestId , oneshot:: Sender < LSPS1OrderStatus > > > ,
66
68
pending_check_order_status_requests :
67
- Mutex < HashMap < RequestId , oneshot:: Sender < LSPS1OrderStatus > > > ,
69
+ Mutex < HashMap < LSPSRequestId , oneshot:: Sender < LSPS1OrderStatus > > > ,
68
70
}
69
71
70
72
#[ derive( Debug , Clone ) ]
@@ -79,8 +81,8 @@ struct LSPS2Client {
79
81
lsp_address : SocketAddress ,
80
82
token : Option < String > ,
81
83
ldk_client_config : LdkLSPS2ClientConfig ,
82
- pending_fee_requests : Mutex < HashMap < RequestId , oneshot:: Sender < LSPS2FeeResponse > > > ,
83
- pending_buy_requests : Mutex < HashMap < RequestId , oneshot:: Sender < LSPS2BuyResponse > > > ,
84
+ pending_fee_requests : Mutex < HashMap < LSPSRequestId , oneshot:: Sender < LSPS2FeeResponse > > > ,
85
+ pending_buy_requests : Mutex < HashMap < LSPSRequestId , oneshot:: Sender < LSPS2BuyResponse > > > ,
84
86
}
85
87
86
88
#[ derive( Debug , Clone ) ]
@@ -293,7 +295,7 @@ where
293
295
294
296
pub ( crate ) async fn handle_next_event ( & self ) {
295
297
match self . liquidity_manager . next_event_async ( ) . await {
296
- Event :: LSPS1Client ( LSPS1ClientEvent :: SupportedOptionsReady {
298
+ LiquidityEvent :: LSPS1Client ( LSPS1ClientEvent :: SupportedOptionsReady {
297
299
request_id,
298
300
counterparty_node_id,
299
301
supported_options,
@@ -346,7 +348,7 @@ where
346
348
) ;
347
349
}
348
350
} ,
349
- Event :: LSPS1Client ( LSPS1ClientEvent :: OrderCreated {
351
+ LiquidityEvent :: LSPS1Client ( LSPS1ClientEvent :: OrderCreated {
350
352
request_id,
351
353
counterparty_node_id,
352
354
order_id,
@@ -404,7 +406,7 @@ where
404
406
log_error ! ( self . logger, "Received unexpected LSPS1Client::OrderCreated event!" ) ;
405
407
}
406
408
} ,
407
- Event :: LSPS1Client ( LSPS1ClientEvent :: OrderStatus {
409
+ LiquidityEvent :: LSPS1Client ( LSPS1ClientEvent :: OrderStatus {
408
410
request_id,
409
411
counterparty_node_id,
410
412
order_id,
@@ -462,7 +464,7 @@ where
462
464
log_error ! ( self . logger, "Received unexpected LSPS1Client::OrderStatus event!" ) ;
463
465
}
464
466
} ,
465
- Event :: LSPS2Service ( LSPS2ServiceEvent :: GetInfo {
467
+ LiquidityEvent :: LSPS2Service ( LSPS2ServiceEvent :: GetInfo {
466
468
request_id,
467
469
counterparty_node_id,
468
470
token,
@@ -501,10 +503,8 @@ where
501
503
}
502
504
}
503
505
504
- let mut valid_until: DateTime < Utc > = Utc :: now ( ) ;
505
- valid_until += LSPS2_GETINFO_REQUEST_EXPIRY ;
506
-
507
- let opening_fee_params = RawOpeningFeeParams {
506
+ let valid_until = LSPSDateTime ( Utc :: now ( ) + LSPS2_GETINFO_REQUEST_EXPIRY ) ;
507
+ let opening_fee_params = LSPS2RawOpeningFeeParams {
508
508
min_fee_msat : service_config. min_channel_opening_fee_msat ,
509
509
proportional : service_config. channel_opening_fee_ppm ,
510
510
valid_until,
@@ -532,7 +532,7 @@ where
532
532
return ;
533
533
}
534
534
} ,
535
- Event :: LSPS2Service ( LSPS2ServiceEvent :: BuyRequest {
535
+ LiquidityEvent :: LSPS2Service ( LSPS2ServiceEvent :: BuyRequest {
536
536
request_id,
537
537
counterparty_node_id,
538
538
opening_fee_params : _,
@@ -599,7 +599,7 @@ where
599
599
return ;
600
600
}
601
601
} ,
602
- Event :: LSPS2Service ( LSPS2ServiceEvent :: OpenChannel {
602
+ LiquidityEvent :: LSPS2Service ( LSPS2ServiceEvent :: OpenChannel {
603
603
their_network_key,
604
604
amt_to_forward_msat,
605
605
opening_fee_msat : _,
@@ -713,7 +713,7 @@ where
713
713
} ,
714
714
}
715
715
} ,
716
- Event :: LSPS2Client ( LSPS2ClientEvent :: OpeningParametersReady {
716
+ LiquidityEvent :: LSPS2Client ( LSPS2ClientEvent :: OpeningParametersReady {
717
717
request_id,
718
718
counterparty_node_id,
719
719
opening_fee_params_menu,
@@ -763,7 +763,7 @@ where
763
763
) ;
764
764
}
765
765
} ,
766
- Event :: LSPS2Client ( LSPS2ClientEvent :: InvoiceParametersReady {
766
+ LiquidityEvent :: LSPS2Client ( LSPS2ClientEvent :: InvoiceParametersReady {
767
767
request_id,
768
768
counterparty_node_id,
769
769
intercept_scid,
@@ -903,7 +903,7 @@ where
903
903
return Err ( Error :: LiquidityRequestFailed ) ;
904
904
}
905
905
906
- let order_params = OrderParameters {
906
+ let order_params = LSPS1OrderParams {
907
907
lsp_balance_sat,
908
908
client_balance_sat,
909
909
required_channel_confirmations : lsp_limits. min_required_channel_confirmations ,
@@ -952,7 +952,7 @@ where
952
952
}
953
953
954
954
pub ( crate ) async fn lsps1_check_order_status (
955
- & self , order_id : OrderId ,
955
+ & self , order_id : LSPS1OrderId ,
956
956
) -> Result < LSPS1OrderStatus , Error > {
957
957
let lsps1_client = self . lsps1_client . as_ref ( ) . ok_or ( Error :: LiquiditySourceUnavailable ) ?;
958
958
let client_handler = self . liquidity_manager . lsps1_client_handler ( ) . ok_or_else ( || {
@@ -1120,7 +1120,7 @@ where
1120
1120
}
1121
1121
1122
1122
async fn lsps2_send_buy_request (
1123
- & self , amount_msat : Option < u64 > , opening_fee_params : OpeningFeeParams ,
1123
+ & self , amount_msat : Option < u64 > , opening_fee_params : LSPS2OpeningFeeParams ,
1124
1124
) -> Result < LSPS2BuyResponse , Error > {
1125
1125
let lsps2_client = self . lsps2_client . as_ref ( ) . ok_or ( Error :: LiquiditySourceUnavailable ) ?;
1126
1126
@@ -1291,32 +1291,32 @@ pub(crate) struct LSPS1OpeningParamsResponse {
1291
1291
#[ derive( Debug , Clone ) ]
1292
1292
pub struct LSPS1OrderStatus {
1293
1293
/// The id of the channel order.
1294
- pub order_id : OrderId ,
1294
+ pub order_id : LSPS1OrderId ,
1295
1295
/// The parameters of channel order.
1296
- pub order_params : OrderParameters ,
1296
+ pub order_params : LSPS1OrderParams ,
1297
1297
/// Contains details about how to pay for the order.
1298
- pub payment_options : PaymentInfo ,
1298
+ pub payment_options : LSPS1PaymentInfo ,
1299
1299
/// Contains information about the channel state.
1300
- pub channel_state : Option < ChannelInfo > ,
1300
+ pub channel_state : Option < LSPS1ChannelInfo > ,
1301
1301
}
1302
1302
1303
1303
#[ cfg( not( feature = "uniffi" ) ) ]
1304
- type PaymentInfo = lightning_liquidity:: lsps1:: msgs:: PaymentInfo ;
1304
+ type LSPS1PaymentInfo = lightning_liquidity:: lsps1:: msgs:: LSPS1PaymentInfo ;
1305
1305
1306
1306
/// Details regarding how to pay for an order.
1307
1307
#[ cfg( feature = "uniffi" ) ]
1308
1308
#[ derive( Clone , Debug , PartialEq , Eq ) ]
1309
- pub struct PaymentInfo {
1309
+ pub struct LSPS1PaymentInfo {
1310
1310
/// A Lightning payment using BOLT 11.
1311
- pub bolt11 : Option < crate :: uniffi_types:: Bolt11PaymentInfo > ,
1311
+ pub bolt11 : Option < crate :: uniffi_types:: LSPS1Bolt11PaymentInfo > ,
1312
1312
/// An onchain payment.
1313
- pub onchain : Option < OnchainPaymentInfo > ,
1313
+ pub onchain : Option < LSPS1OnchainPaymentInfo > ,
1314
1314
}
1315
1315
1316
1316
#[ cfg( feature = "uniffi" ) ]
1317
- impl From < lightning_liquidity:: lsps1:: msgs:: PaymentInfo > for PaymentInfo {
1318
- fn from ( value : lightning_liquidity:: lsps1:: msgs:: PaymentInfo ) -> Self {
1319
- PaymentInfo {
1317
+ impl From < lightning_liquidity:: lsps1:: msgs:: LSPS1PaymentInfo > for LSPS1PaymentInfo {
1318
+ fn from ( value : lightning_liquidity:: lsps1:: msgs:: LSPS1PaymentInfo ) -> Self {
1319
+ LSPS1PaymentInfo {
1320
1320
bolt11 : value. bolt11 . map ( |b| b. into ( ) ) ,
1321
1321
onchain : value. onchain . map ( |o| o. into ( ) ) ,
1322
1322
}
@@ -1326,11 +1326,11 @@ impl From<lightning_liquidity::lsps1::msgs::PaymentInfo> for PaymentInfo {
1326
1326
/// An onchain payment.
1327
1327
#[ cfg( feature = "uniffi" ) ]
1328
1328
#[ derive( Clone , Debug , PartialEq , Eq ) ]
1329
- pub struct OnchainPaymentInfo {
1329
+ pub struct LSPS1OnchainPaymentInfo {
1330
1330
/// Indicates the current state of the payment.
1331
- pub state : lightning_liquidity:: lsps1:: msgs:: PaymentState ,
1331
+ pub state : lightning_liquidity:: lsps1:: msgs:: LSPS1PaymentState ,
1332
1332
/// The datetime when the payment option expires.
1333
- pub expires_at : chrono :: DateTime < chrono :: Utc > ,
1333
+ pub expires_at : LSPSDateTime ,
1334
1334
/// The total fee the LSP will charge to open this channel in satoshi.
1335
1335
pub fee_total_sat : u64 ,
1336
1336
/// The amount the client needs to pay to have the requested channel openend.
@@ -1349,8 +1349,8 @@ pub struct OnchainPaymentInfo {
1349
1349
}
1350
1350
1351
1351
#[ cfg( feature = "uniffi" ) ]
1352
- impl From < lightning_liquidity:: lsps1:: msgs:: OnchainPaymentInfo > for OnchainPaymentInfo {
1353
- fn from ( value : lightning_liquidity:: lsps1:: msgs:: OnchainPaymentInfo ) -> Self {
1352
+ impl From < lightning_liquidity:: lsps1:: msgs:: LSPS1OnchainPaymentInfo > for LSPS1OnchainPaymentInfo {
1353
+ fn from ( value : lightning_liquidity:: lsps1:: msgs:: LSPS1OnchainPaymentInfo ) -> Self {
1354
1354
Self {
1355
1355
state : value. state ,
1356
1356
expires_at : value. expires_at ,
@@ -1366,7 +1366,7 @@ impl From<lightning_liquidity::lsps1::msgs::OnchainPaymentInfo> for OnchainPayme
1366
1366
1367
1367
#[ derive( Debug , Clone ) ]
1368
1368
pub ( crate ) struct LSPS2FeeResponse {
1369
- opening_fee_params_menu : Vec < OpeningFeeParams > ,
1369
+ opening_fee_params_menu : Vec < LSPS2OpeningFeeParams > ,
1370
1370
}
1371
1371
1372
1372
#[ derive( Debug , Clone ) ]
@@ -1456,7 +1456,7 @@ impl LSPS1Liquidity {
1456
1456
}
1457
1457
1458
1458
/// Connects to the configured LSP and checks for the status of a previously-placed order.
1459
- pub fn check_order_status ( & self , order_id : OrderId ) -> Result < LSPS1OrderStatus , Error > {
1459
+ pub fn check_order_status ( & self , order_id : LSPS1OrderId ) -> Result < LSPS1OrderStatus , Error > {
1460
1460
let liquidity_source =
1461
1461
self . liquidity_source . as_ref ( ) . ok_or ( Error :: LiquiditySourceUnavailable ) ?;
1462
1462
0 commit comments