@@ -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 ,
@@ -24,7 +25,7 @@ use crate::io::{
2425 EVENT_QUEUE_PERSISTENCE_KEY , EVENT_QUEUE_PERSISTENCE_PRIMARY_NAMESPACE ,
2526 EVENT_QUEUE_PERSISTENCE_SECONDARY_NAMESPACE ,
2627} ;
27- use crate :: logger:: { log_debug, log_error, log_info, Logger } ;
28+ use crate :: logger:: { log_debug, log_error, log_info, FilesystemLogger , Logger } ;
2829
2930use lightning:: events:: bump_transaction:: BumpTransactionEvent ;
3031use lightning:: events:: { ClosureReason , PaymentPurpose , ReplayEvent } ;
@@ -432,6 +433,7 @@ where
432433 connection_manager : Arc < ConnectionManager < L > > ,
433434 output_sweeper : Arc < Sweeper > ,
434435 network_graph : Arc < Graph > ,
436+ liquidity_source : Option < Arc < LiquiditySource < Arc < FilesystemLogger > > > > ,
435437 payment_store : Arc < PaymentStore < L > > ,
436438 peer_store : Arc < PeerStore < L > > ,
437439 runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > ,
@@ -448,6 +450,7 @@ where
448450 bump_tx_event_handler : Arc < BumpTransactionEventHandler > ,
449451 channel_manager : Arc < ChannelManager > , connection_manager : Arc < ConnectionManager < L > > ,
450452 output_sweeper : Arc < Sweeper > , network_graph : Arc < Graph > ,
453+ liquidity_source : Option < Arc < LiquiditySource < Arc < FilesystemLogger > > > > ,
451454 payment_store : Arc < PaymentStore < L > > , peer_store : Arc < PeerStore < L > > ,
452455 runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > , logger : L , config : Arc < Config > ,
453456 ) -> Self {
@@ -459,6 +462,7 @@ where
459462 connection_manager,
460463 output_sweeper,
461464 network_graph,
465+ liquidity_source,
462466 payment_store,
463467 peer_store,
464468 logger,
@@ -994,7 +998,11 @@ where
994998 LdkEvent :: PaymentPathFailed { .. } => { } ,
995999 LdkEvent :: ProbeSuccessful { .. } => { } ,
9961000 LdkEvent :: ProbeFailed { .. } => { } ,
997- LdkEvent :: HTLCHandlingFailed { .. } => { } ,
1001+ LdkEvent :: HTLCHandlingFailed { failed_next_destination, .. } => {
1002+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1003+ liquidity_source. handle_htlc_handling_failed ( failed_next_destination) ;
1004+ }
1005+ } ,
9981006 LdkEvent :: PendingHTLCsForwardable { time_forwardable } => {
9991007 let forwarding_channel_manager = self . channel_manager . clone ( ) ;
10001008 let min = time_forwardable. as_millis ( ) as u64 ;
@@ -1211,6 +1219,10 @@ where
12111219 fee_earned,
12121220 ) ;
12131221 }
1222+
1223+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1224+ liquidity_source. handle_payment_forwarded ( next_channel_id) ;
1225+ }
12141226 } ,
12151227 LdkEvent :: ChannelPending {
12161228 channel_id,
@@ -1284,6 +1296,14 @@ where
12841296 counterparty_node_id,
12851297 ) ;
12861298
1299+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1300+ liquidity_source. handle_channel_ready (
1301+ user_channel_id,
1302+ & channel_id,
1303+ & counterparty_node_id,
1304+ ) ;
1305+ }
1306+
12871307 let event = Event :: ChannelReady {
12881308 channel_id,
12891309 user_channel_id : UserChannelId ( user_channel_id) ,
@@ -1322,7 +1342,22 @@ where
13221342 } ;
13231343 } ,
13241344 LdkEvent :: DiscardFunding { .. } => { } ,
1325- LdkEvent :: HTLCIntercepted { .. } => { } ,
1345+ LdkEvent :: HTLCIntercepted {
1346+ requested_next_hop_scid,
1347+ intercept_id,
1348+ expected_outbound_amount_msat,
1349+ payment_hash,
1350+ ..
1351+ } => {
1352+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1353+ liquidity_source. handle_htlc_intercepted (
1354+ requested_next_hop_scid,
1355+ intercept_id,
1356+ expected_outbound_amount_msat,
1357+ payment_hash,
1358+ ) ;
1359+ }
1360+ } ,
13261361 LdkEvent :: InvoiceReceived { .. } => {
13271362 debug_assert ! ( false , "We currently don't handle BOLT12 invoices manually, so this event should never be emitted." ) ;
13281363 } ,
0 commit comments