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 @@ -451,6 +451,18 @@ impl OutboundJITChannel {
451451 self . state = new_state;
452452 Ok ( action)
453453 }
454+
455+ fn is_prunable ( & self ) -> bool {
456+ // We deem an OutboundJITChannel prunable if our offer expired and we haven't intercepted
457+ // any HTLCs initiating the flow yet.
458+ let is_pending_initial_payment = match self . state {
459+ OutboundJITChannelState :: PendingInitialPayment { .. } => true ,
460+ _ => false ,
461+ } ;
462+
463+ let is_expired = is_expired_opening_fee_params ( & self . opening_fee_params ) ;
464+ is_pending_initial_payment && is_expired
465+ }
454466}
455467
456468struct PeerState {
@@ -488,6 +500,16 @@ impl PeerState {
488500 } ,
489501 }
490502 } ) ;
503+
504+ self . outbound_channels_by_intercept_scid . retain ( |intercept_scid, entry| {
505+ if entry. is_prunable ( ) {
506+ // We abort the flow, and prune any data kept.
507+ self . intercept_scid_by_channel_id . retain ( |_, iscid| intercept_scid != iscid) ;
508+ self . intercept_scid_by_user_channel_id . retain ( |_, iscid| intercept_scid != iscid) ;
509+ return false ;
510+ }
511+ true
512+ } ) ;
491513 }
492514}
493515
You can’t perform that action at this time.
0 commit comments