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