@@ -14,6 +14,7 @@ use crate::{
14
14
15
15
use crate :: connection:: ConnectionManager ;
16
16
use crate :: fee_estimator:: ConfirmationTarget ;
17
+ use crate :: liquidity:: LiquiditySource ;
17
18
18
19
use crate :: payment:: store:: {
19
20
PaymentDetails , PaymentDetailsUpdate , PaymentDirection , PaymentKind , PaymentStatus ,
@@ -24,7 +25,7 @@ use crate::io::{
24
25
EVENT_QUEUE_PERSISTENCE_KEY , EVENT_QUEUE_PERSISTENCE_PRIMARY_NAMESPACE ,
25
26
EVENT_QUEUE_PERSISTENCE_SECONDARY_NAMESPACE ,
26
27
} ;
27
- use crate :: logger:: { log_debug, log_error, log_info, Logger } ;
28
+ use crate :: logger:: { log_debug, log_error, log_info, FilesystemLogger , Logger } ;
28
29
29
30
use lightning:: events:: bump_transaction:: BumpTransactionEvent ;
30
31
use lightning:: events:: { ClosureReason , PaymentPurpose , ReplayEvent } ;
@@ -445,6 +446,7 @@ where
445
446
connection_manager : Arc < ConnectionManager < L > > ,
446
447
output_sweeper : Arc < Sweeper > ,
447
448
network_graph : Arc < Graph > ,
449
+ liquidity_source : Option < Arc < LiquiditySource < Arc < FilesystemLogger > > > > ,
448
450
payment_store : Arc < PaymentStore < L > > ,
449
451
peer_store : Arc < PeerStore < L > > ,
450
452
runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > ,
@@ -461,6 +463,7 @@ where
461
463
bump_tx_event_handler : Arc < BumpTransactionEventHandler > ,
462
464
channel_manager : Arc < ChannelManager > , connection_manager : Arc < ConnectionManager < L > > ,
463
465
output_sweeper : Arc < Sweeper > , network_graph : Arc < Graph > ,
466
+ liquidity_source : Option < Arc < LiquiditySource < Arc < FilesystemLogger > > > > ,
464
467
payment_store : Arc < PaymentStore < L > > , peer_store : Arc < PeerStore < L > > ,
465
468
runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > , logger : L , config : Arc < Config > ,
466
469
) -> Self {
@@ -472,6 +475,7 @@ where
472
475
connection_manager,
473
476
output_sweeper,
474
477
network_graph,
478
+ liquidity_source,
475
479
payment_store,
476
480
peer_store,
477
481
logger,
@@ -1009,7 +1013,11 @@ where
1009
1013
LdkEvent :: PaymentPathFailed { .. } => { } ,
1010
1014
LdkEvent :: ProbeSuccessful { .. } => { } ,
1011
1015
LdkEvent :: ProbeFailed { .. } => { } ,
1012
- LdkEvent :: HTLCHandlingFailed { .. } => { } ,
1016
+ LdkEvent :: HTLCHandlingFailed { failed_next_destination, .. } => {
1017
+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1018
+ liquidity_source. handle_htlc_handling_failed ( failed_next_destination) ;
1019
+ }
1020
+ } ,
1013
1021
LdkEvent :: PendingHTLCsForwardable { time_forwardable } => {
1014
1022
let forwarding_channel_manager = self . channel_manager . clone ( ) ;
1015
1023
let min = time_forwardable. as_millis ( ) as u64 ;
@@ -1230,6 +1238,10 @@ where
1230
1238
fee_earned,
1231
1239
) ;
1232
1240
}
1241
+
1242
+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1243
+ liquidity_source. handle_payment_forwarded ( next_channel_id) ;
1244
+ }
1233
1245
} ,
1234
1246
LdkEvent :: ChannelPending {
1235
1247
channel_id,
@@ -1303,6 +1315,14 @@ where
1303
1315
counterparty_node_id,
1304
1316
) ;
1305
1317
1318
+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1319
+ liquidity_source. handle_channel_ready (
1320
+ user_channel_id,
1321
+ & channel_id,
1322
+ & counterparty_node_id,
1323
+ ) ;
1324
+ }
1325
+
1306
1326
let event = Event :: ChannelReady {
1307
1327
channel_id,
1308
1328
user_channel_id : UserChannelId ( user_channel_id) ,
@@ -1341,7 +1361,22 @@ where
1341
1361
} ;
1342
1362
} ,
1343
1363
LdkEvent :: DiscardFunding { .. } => { } ,
1344
- LdkEvent :: HTLCIntercepted { .. } => { } ,
1364
+ LdkEvent :: HTLCIntercepted {
1365
+ requested_next_hop_scid,
1366
+ intercept_id,
1367
+ expected_outbound_amount_msat,
1368
+ payment_hash,
1369
+ ..
1370
+ } => {
1371
+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1372
+ liquidity_source. handle_htlc_intercepted (
1373
+ requested_next_hop_scid,
1374
+ intercept_id,
1375
+ expected_outbound_amount_msat,
1376
+ payment_hash,
1377
+ ) ;
1378
+ }
1379
+ } ,
1345
1380
LdkEvent :: InvoiceReceived { .. } => {
1346
1381
debug_assert ! ( false , "We currently don't handle BOLT12 invoices manually, so this event should never be emitted." ) ;
1347
1382
} ,
0 commit comments