File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
lightning-liquidity/src/lsps2 Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -435,6 +435,18 @@ impl OutboundJITChannel {
435435 self . state = new_state;
436436 Ok ( action)
437437 }
438+
439+ fn is_prunable ( & self ) -> bool {
440+ // We deem an OutboundJITChannel prunable if our offer expired and we haven't intercepted
441+ // any HTLCs initiating the flow yet.
442+ let is_pending_initial_payment = match self . state {
443+ OutboundJITChannelState :: PendingInitialPayment { .. } => true ,
444+ _ => false ,
445+ } ;
446+
447+ let is_expired = is_expired_opening_fee_params ( & self . opening_fee_params ) ;
448+ is_pending_initial_payment && is_expired
449+ }
438450}
439451
440452struct PeerState {
@@ -472,6 +484,16 @@ impl PeerState {
472484 } ,
473485 }
474486 } ) ;
487+
488+ self . outbound_channels_by_intercept_scid . retain ( |intercept_scid, entry| {
489+ if entry. is_prunable ( ) {
490+ // We abort the flow, and prune any data kept.
491+ self . intercept_scid_by_channel_id . retain ( |_, iscid| intercept_scid != iscid) ;
492+ self . intercept_scid_by_user_channel_id . retain ( |_, iscid| intercept_scid != iscid) ;
493+ return false ;
494+ }
495+ true
496+ } ) ;
475497 }
476498}
477499
You can’t perform that action at this time.
0 commit comments