@@ -15,6 +15,8 @@ use crate::{
1515use crate :: config:: { may_announce_channel, Config } ;
1616use crate :: connection:: ConnectionManager ;
1717use crate :: fee_estimator:: ConfirmationTarget ;
18+ use crate :: liquidity:: LiquiditySource ;
19+ use crate :: logger:: Logger ;
1820
1921use crate :: payment:: store:: {
2022 PaymentDetails , PaymentDetailsUpdate , PaymentDirection , PaymentKind , PaymentStatus ,
@@ -446,6 +448,7 @@ where
446448 connection_manager : Arc < ConnectionManager < L > > ,
447449 output_sweeper : Arc < Sweeper > ,
448450 network_graph : Arc < Graph > ,
451+ liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
449452 payment_store : Arc < PaymentStore < L > > ,
450453 peer_store : Arc < PeerStore < L > > ,
451454 runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > ,
@@ -462,6 +465,7 @@ where
462465 bump_tx_event_handler : Arc < BumpTransactionEventHandler > ,
463466 channel_manager : Arc < ChannelManager > , connection_manager : Arc < ConnectionManager < L > > ,
464467 output_sweeper : Arc < Sweeper > , network_graph : Arc < Graph > ,
468+ liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
465469 payment_store : Arc < PaymentStore < L > > , peer_store : Arc < PeerStore < L > > ,
466470 runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > , logger : L , config : Arc < Config > ,
467471 ) -> Self {
@@ -473,6 +477,7 @@ where
473477 connection_manager,
474478 output_sweeper,
475479 network_graph,
480+ liquidity_source,
476481 payment_store,
477482 peer_store,
478483 logger,
@@ -1013,7 +1018,11 @@ where
10131018 LdkEvent :: PaymentPathFailed { .. } => { } ,
10141019 LdkEvent :: ProbeSuccessful { .. } => { } ,
10151020 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+ } ,
10171026 LdkEvent :: PendingHTLCsForwardable { time_forwardable } => {
10181027 let forwarding_channel_manager = self . channel_manager . clone ( ) ;
10191028 let min = time_forwardable. as_millis ( ) as u64 ;
@@ -1248,6 +1257,10 @@ where
12481257 fee_earned,
12491258 ) ;
12501259 }
1260+
1261+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1262+ liquidity_source. handle_payment_forwarded ( next_channel_id) ;
1263+ }
12511264 } ,
12521265 LdkEvent :: ChannelPending {
12531266 channel_id,
@@ -1321,6 +1334,14 @@ where
13211334 counterparty_node_id,
13221335 ) ;
13231336
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+
13241345 let event = Event :: ChannelReady {
13251346 channel_id,
13261347 user_channel_id : UserChannelId ( user_channel_id) ,
@@ -1359,7 +1380,22 @@ where
13591380 } ;
13601381 } ,
13611382 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+ } ,
13631399 LdkEvent :: InvoiceReceived { .. } => {
13641400 debug_assert ! ( false , "We currently don't handle BOLT12 invoices manually, so this event should never be emitted." ) ;
13651401 } ,
0 commit comments