@@ -15,6 +15,8 @@ use crate::{
15
15
use crate :: config:: { may_announce_channel, Config } ;
16
16
use crate :: connection:: ConnectionManager ;
17
17
use crate :: fee_estimator:: ConfirmationTarget ;
18
+ use crate :: liquidity:: LiquiditySource ;
19
+ use crate :: logger:: Logger ;
18
20
19
21
use crate :: payment:: store:: {
20
22
PaymentDetails , PaymentDetailsUpdate , PaymentDirection , PaymentKind , PaymentStatus ,
@@ -446,6 +448,7 @@ where
446
448
connection_manager : Arc < ConnectionManager < L > > ,
447
449
output_sweeper : Arc < Sweeper > ,
448
450
network_graph : Arc < Graph > ,
451
+ liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
449
452
payment_store : Arc < PaymentStore < L > > ,
450
453
peer_store : Arc < PeerStore < L > > ,
451
454
runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > ,
@@ -462,6 +465,7 @@ where
462
465
bump_tx_event_handler : Arc < BumpTransactionEventHandler > ,
463
466
channel_manager : Arc < ChannelManager > , connection_manager : Arc < ConnectionManager < L > > ,
464
467
output_sweeper : Arc < Sweeper > , network_graph : Arc < Graph > ,
468
+ liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
465
469
payment_store : Arc < PaymentStore < L > > , peer_store : Arc < PeerStore < L > > ,
466
470
runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > , logger : L , config : Arc < Config > ,
467
471
) -> Self {
@@ -473,6 +477,7 @@ where
473
477
connection_manager,
474
478
output_sweeper,
475
479
network_graph,
480
+ liquidity_source,
476
481
payment_store,
477
482
peer_store,
478
483
logger,
@@ -1013,7 +1018,11 @@ where
1013
1018
LdkEvent :: PaymentPathFailed { .. } => { } ,
1014
1019
LdkEvent :: ProbeSuccessful { .. } => { } ,
1015
1020
LdkEvent :: ProbeFailed { .. } => { } ,
1016
- LdkEvent :: HTLCHandlingFailed { .. } => { } ,
1021
+ LdkEvent :: HTLCHandlingFailed { failed_next_destination, .. } => {
1022
+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1023
+ liquidity_source. handle_htlc_handling_failed ( failed_next_destination) ;
1024
+ }
1025
+ } ,
1017
1026
LdkEvent :: PendingHTLCsForwardable { time_forwardable } => {
1018
1027
let forwarding_channel_manager = self . channel_manager . clone ( ) ;
1019
1028
let min = time_forwardable. as_millis ( ) as u64 ;
@@ -1248,6 +1257,10 @@ where
1248
1257
fee_earned,
1249
1258
) ;
1250
1259
}
1260
+
1261
+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1262
+ liquidity_source. handle_payment_forwarded ( next_channel_id) ;
1263
+ }
1251
1264
} ,
1252
1265
LdkEvent :: ChannelPending {
1253
1266
channel_id,
@@ -1321,6 +1334,14 @@ where
1321
1334
counterparty_node_id,
1322
1335
) ;
1323
1336
1337
+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1338
+ liquidity_source. handle_channel_ready (
1339
+ user_channel_id,
1340
+ & channel_id,
1341
+ & counterparty_node_id,
1342
+ ) ;
1343
+ }
1344
+
1324
1345
let event = Event :: ChannelReady {
1325
1346
channel_id,
1326
1347
user_channel_id : UserChannelId ( user_channel_id) ,
@@ -1359,7 +1380,22 @@ where
1359
1380
} ;
1360
1381
} ,
1361
1382
LdkEvent :: DiscardFunding { .. } => { } ,
1362
- LdkEvent :: HTLCIntercepted { .. } => { } ,
1383
+ LdkEvent :: HTLCIntercepted {
1384
+ requested_next_hop_scid,
1385
+ intercept_id,
1386
+ expected_outbound_amount_msat,
1387
+ payment_hash,
1388
+ ..
1389
+ } => {
1390
+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1391
+ liquidity_source. handle_htlc_intercepted (
1392
+ requested_next_hop_scid,
1393
+ intercept_id,
1394
+ expected_outbound_amount_msat,
1395
+ payment_hash,
1396
+ ) ;
1397
+ }
1398
+ } ,
1363
1399
LdkEvent :: InvoiceReceived { .. } => {
1364
1400
debug_assert ! ( false , "We currently don't handle BOLT12 invoices manually, so this event should never be emitted." ) ;
1365
1401
} ,
0 commit comments