mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-15 15:39:09 +01:00
LSPS2: Also prune expired OutboundJITChannels
pending initial payments
We're now also pruning any expired `OutboundJITChannels` if we haven't seen any related HTLCs.
This commit is contained in:
parent
b39c8b09ba
commit
776ede44cb
1 changed files with 22 additions and 0 deletions
|
@ -435,6 +435,18 @@ impl OutboundJITChannel {
|
|||
self.state = new_state;
|
||||
Ok(action)
|
||||
}
|
||||
|
||||
fn is_prunable(&self) -> bool {
|
||||
// We deem an OutboundJITChannel prunable if our offer expired and we haven't intercepted
|
||||
// any HTLCs initiating the flow yet.
|
||||
let is_pending_initial_payment = match self.state {
|
||||
OutboundJITChannelState::PendingInitialPayment { .. } => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
let is_expired = is_expired_opening_fee_params(&self.opening_fee_params);
|
||||
is_pending_initial_payment && is_expired
|
||||
}
|
||||
}
|
||||
|
||||
struct PeerState {
|
||||
|
@ -472,6 +484,16 @@ impl PeerState {
|
|||
},
|
||||
}
|
||||
});
|
||||
|
||||
self.outbound_channels_by_intercept_scid.retain(|intercept_scid, entry| {
|
||||
if entry.is_prunable() {
|
||||
// We abort the flow, and prune any data kept.
|
||||
self.intercept_scid_by_channel_id.retain(|_, iscid| intercept_scid != iscid);
|
||||
self.intercept_scid_by_user_channel_id.retain(|_, iscid| intercept_scid != iscid);
|
||||
return false;
|
||||
}
|
||||
true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue