@@ -14,6 +14,7 @@ use crate::{
14
14
15
15
use crate :: connection:: ConnectionManager ;
16
16
use crate :: fee_estimator:: ConfirmationTarget ;
17
+ use crate :: liquidity:: LiquiditySource ;
17
18
18
19
use crate :: payment:: store:: {
19
20
PaymentDetails , PaymentDetailsUpdate , PaymentDirection , PaymentKind , PaymentStatus ,
@@ -24,7 +25,7 @@ use crate::io::{
24
25
EVENT_QUEUE_PERSISTENCE_KEY , EVENT_QUEUE_PERSISTENCE_PRIMARY_NAMESPACE ,
25
26
EVENT_QUEUE_PERSISTENCE_SECONDARY_NAMESPACE ,
26
27
} ;
27
- use crate :: logger:: { log_debug, log_error, log_info, Logger } ;
28
+ use crate :: logger:: { log_debug, log_error, log_info, FilesystemLogger , Logger } ;
28
29
29
30
use lightning:: events:: bump_transaction:: BumpTransactionEvent ;
30
31
use lightning:: events:: { ClosureReason , PaymentPurpose , ReplayEvent } ;
@@ -432,6 +433,7 @@ where
432
433
connection_manager : Arc < ConnectionManager < L > > ,
433
434
output_sweeper : Arc < Sweeper > ,
434
435
network_graph : Arc < Graph > ,
436
+ liquidity_source : Option < Arc < LiquiditySource < Arc < FilesystemLogger > > > > ,
435
437
payment_store : Arc < PaymentStore < L > > ,
436
438
peer_store : Arc < PeerStore < L > > ,
437
439
runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > ,
@@ -448,6 +450,7 @@ where
448
450
bump_tx_event_handler : Arc < BumpTransactionEventHandler > ,
449
451
channel_manager : Arc < ChannelManager > , connection_manager : Arc < ConnectionManager < L > > ,
450
452
output_sweeper : Arc < Sweeper > , network_graph : Arc < Graph > ,
453
+ liquidity_source : Option < Arc < LiquiditySource < Arc < FilesystemLogger > > > > ,
451
454
payment_store : Arc < PaymentStore < L > > , peer_store : Arc < PeerStore < L > > ,
452
455
runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > , logger : L , config : Arc < Config > ,
453
456
) -> Self {
@@ -459,6 +462,7 @@ where
459
462
connection_manager,
460
463
output_sweeper,
461
464
network_graph,
465
+ liquidity_source,
462
466
payment_store,
463
467
peer_store,
464
468
logger,
@@ -994,7 +998,11 @@ where
994
998
LdkEvent :: PaymentPathFailed { .. } => { } ,
995
999
LdkEvent :: ProbeSuccessful { .. } => { } ,
996
1000
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
+ } ,
998
1006
LdkEvent :: PendingHTLCsForwardable { time_forwardable } => {
999
1007
let forwarding_channel_manager = self . channel_manager . clone ( ) ;
1000
1008
let min = time_forwardable. as_millis ( ) as u64 ;
@@ -1211,6 +1219,10 @@ where
1211
1219
fee_earned,
1212
1220
) ;
1213
1221
}
1222
+
1223
+ if let Some ( liquidity_source) = self . liquidity_source . as_ref ( ) {
1224
+ liquidity_source. handle_payment_forwarded ( next_channel_id) ;
1225
+ }
1214
1226
} ,
1215
1227
LdkEvent :: ChannelPending {
1216
1228
channel_id,
@@ -1284,6 +1296,14 @@ where
1284
1296
counterparty_node_id,
1285
1297
) ;
1286
1298
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
+
1287
1307
let event = Event :: ChannelReady {
1288
1308
channel_id,
1289
1309
user_channel_id : UserChannelId ( user_channel_id) ,
@@ -1322,7 +1342,22 @@ where
1322
1342
} ;
1323
1343
} ,
1324
1344
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
+ } ,
1326
1361
LdkEvent :: InvoiceReceived { .. } => {
1327
1362
debug_assert ! ( false , "We currently don't handle BOLT12 invoices manually, so this event should never be emitted." ) ;
1328
1363
} ,
0 commit comments