@@ -14,6 +14,8 @@ use crate::{
1414
1515use crate :: connection:: ConnectionManager ;
1616use crate :: fee_estimator:: ConfirmationTarget ;
17+ use crate :: liquidity:: LiquiditySource ;
18+ use crate :: logger:: Logger ;
1719
1820use crate :: payment:: store:: {
1921 PaymentDetails , PaymentDetailsUpdate , PaymentDirection , PaymentKind , PaymentStatus ,
@@ -445,6 +447,7 @@ where
445447 connection_manager : Arc < ConnectionManager < L > > ,
446448 output_sweeper : Arc < Sweeper > ,
447449 network_graph : Arc < Graph > ,
450+ liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
448451 payment_store : Arc < PaymentStore < L > > ,
449452 peer_store : Arc < PeerStore < L > > ,
450453 runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > ,
@@ -461,6 +464,7 @@ where
461464 bump_tx_event_handler : Arc < BumpTransactionEventHandler > ,
462465 channel_manager : Arc < ChannelManager > , connection_manager : Arc < ConnectionManager < L > > ,
463466 output_sweeper : Arc < Sweeper > , network_graph : Arc < Graph > ,
467+ liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
464468 payment_store : Arc < PaymentStore < L > > , peer_store : Arc < PeerStore < L > > ,
465469 runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > , logger : L , config : Arc < Config > ,
466470 ) -> Self {
@@ -472,6 +476,7 @@ where
472476 connection_manager,
473477 output_sweeper,
474478 network_graph,
479+ liquidity_source,
475480 payment_store,
476481 peer_store,
477482 logger,
@@ -1009,7 +1014,11 @@ where
10091014 LdkEvent :: PaymentPathFailed { .. } => { } ,
10101015 LdkEvent :: ProbeSuccessful { .. } => { } ,
10111016 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+ } ,
10131022 LdkEvent :: PendingHTLCsForwardable { time_forwardable } => {
10141023 let forwarding_channel_manager = self . channel_manager . clone ( ) ;
10151024 let min = time_forwardable. as_millis ( ) as u64 ;
@@ -1230,6 +1239,10 @@ where
12301239 fee_earned,
12311240 ) ;
12321241 }
1242+
1243+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1244+ liquidity_source. handle_payment_forwarded ( next_channel_id) ;
1245+ }
12331246 } ,
12341247 LdkEvent :: ChannelPending {
12351248 channel_id,
@@ -1303,6 +1316,14 @@ where
13031316 counterparty_node_id,
13041317 ) ;
13051318
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+
13061327 let event = Event :: ChannelReady {
13071328 channel_id,
13081329 user_channel_id : UserChannelId ( user_channel_id) ,
@@ -1341,7 +1362,22 @@ where
13411362 } ;
13421363 } ,
13431364 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+ } ,
13451381 LdkEvent :: InvoiceReceived { .. } => {
13461382 debug_assert ! ( false , "We currently don't handle BOLT12 invoices manually, so this event should never be emitted." ) ;
13471383 } ,
0 commit comments