@@ -14,6 +14,7 @@ use crate::{
1414
1515use crate :: connection:: ConnectionManager ;
1616use crate :: fee_estimator:: ConfirmationTarget ;
17+ use crate :: liquidity:: LiquiditySource ;
1718
1819use crate :: payment:: store:: {
1920 PaymentDetails , PaymentDetailsUpdate , PaymentDirection , PaymentKind , PaymentStatus ,
@@ -445,6 +446,7 @@ where
445446 connection_manager : Arc < ConnectionManager < L > > ,
446447 output_sweeper : Arc < Sweeper > ,
447448 network_graph : Arc < Graph > ,
449+ liquidity_source : Option < Arc < LiquiditySource < Arc < FilesystemLogger > > > > ,
448450 payment_store : Arc < PaymentStore < L > > ,
449451 peer_store : Arc < PeerStore < L > > ,
450452 runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > ,
@@ -461,6 +463,7 @@ where
461463 bump_tx_event_handler : Arc < BumpTransactionEventHandler > ,
462464 channel_manager : Arc < ChannelManager > , connection_manager : Arc < ConnectionManager < L > > ,
463465 output_sweeper : Arc < Sweeper > , network_graph : Arc < Graph > ,
466+ liquidity_source : Option < Arc < LiquiditySource < Arc < FilesystemLogger > > > > ,
464467 payment_store : Arc < PaymentStore < L > > , peer_store : Arc < PeerStore < L > > ,
465468 runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > , logger : L , config : Arc < Config > ,
466469 ) -> Self {
@@ -472,6 +475,7 @@ where
472475 connection_manager,
473476 output_sweeper,
474477 network_graph,
478+ liquidity_source,
475479 payment_store,
476480 peer_store,
477481 logger,
@@ -1009,7 +1013,11 @@ where
10091013 LdkEvent :: PaymentPathFailed { .. } => { } ,
10101014 LdkEvent :: ProbeSuccessful { .. } => { } ,
10111015 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+ } ,
10131021 LdkEvent :: PendingHTLCsForwardable { time_forwardable } => {
10141022 let forwarding_channel_manager = self . channel_manager . clone ( ) ;
10151023 let min = time_forwardable. as_millis ( ) as u64 ;
@@ -1230,6 +1238,10 @@ where
12301238 fee_earned,
12311239 ) ;
12321240 }
1241+
1242+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1243+ liquidity_source. handle_payment_forwarded ( next_channel_id) ;
1244+ }
12331245 } ,
12341246 LdkEvent :: ChannelPending {
12351247 channel_id,
@@ -1303,6 +1315,14 @@ where
13031315 counterparty_node_id,
13041316 ) ;
13051317
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+
13061326 let event = Event :: ChannelReady {
13071327 channel_id,
13081328 user_channel_id : UserChannelId ( user_channel_id) ,
@@ -1341,7 +1361,22 @@ where
13411361 } ;
13421362 } ,
13431363 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+ } ,
13451380 LdkEvent :: InvoiceReceived { .. } => {
13461381 debug_assert ! ( false , "We currently don't handle BOLT12 invoices manually, so this event should never be emitted." ) ;
13471382 } ,
0 commit comments