Skip to content

Commit 8f2805a

Browse files
fixup: accept lsps5 requests if lsps2 has an active request in any OutboundJITChannelState
1 parent 109de16 commit 8f2805a

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

lightning-liquidity/src/lsps2/service.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -572,20 +572,12 @@ where
572572
&self.config
573573
}
574574

575-
/// Returns whether the peer has any opening or open JIT channels.
576-
pub(crate) fn has_opening_or_open_jit_channel(&self, counterparty_node_id: &PublicKey) -> bool {
575+
/// Returns whether the peer has any active LSPS2 requests.
576+
pub(crate) fn has_active_requests(&self, counterparty_node_id: &PublicKey) -> bool {
577577
let outer_state_lock = self.per_peer_state.read().unwrap();
578578
outer_state_lock.get(counterparty_node_id).map_or(false, |inner| {
579579
let peer_state = inner.lock().unwrap();
580-
peer_state.outbound_channels_by_intercept_scid.values().any(|chan| {
581-
matches!(
582-
chan.state,
583-
OutboundJITChannelState::PendingChannelOpen { .. }
584-
| OutboundJITChannelState::PendingPaymentForward { .. }
585-
| OutboundJITChannelState::PendingPayment { .. }
586-
| OutboundJITChannelState::PaymentForwarded { .. }
587-
)
588-
})
580+
!peer_state.outbound_channels_by_intercept_scid.is_empty()
589581
})
590582
}
591583

lightning-liquidity/src/lsps5/service.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,9 @@ where
155155
/// Prior activity includes an existing open channel, an active LSPS1 flow,
156156
/// or an LSPS2 flow that has an opening or open JIT channel.
157157
pub(crate) fn can_accept_request(
158-
&self, client_id: &PublicKey, lsps2_has_opening_or_open_jit_channel: bool,
159-
lsps1_has_activity: bool,
158+
&self, client_id: &PublicKey, lsps2_has_active_requests: bool, lsps1_has_activity: bool,
160159
) -> bool {
161-
self.client_has_open_channel(client_id)
162-
|| lsps2_has_opening_or_open_jit_channel
163-
|| lsps1_has_activity
160+
self.client_has_open_channel(client_id) || lsps2_has_active_requests || lsps1_has_activity
164161
}
165162

166163
fn check_prune_stale_webhooks(&self) {

lightning-liquidity/src/manager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,10 @@ where
559559
LSPSMessage::LSPS5(msg @ LSPS5Message::Request(..)) => {
560560
match &self.lsps5_service_handler {
561561
Some(lsps5_service_handler) => {
562-
let lsps2_has_opening_or_open_jit_channel = self
562+
let lsps2_has_active_requests = self
563563
.lsps2_service_handler
564564
.as_ref()
565-
.map_or(false, |h| h.has_opening_or_open_jit_channel(sender_node_id));
565+
.map_or(false, |h| h.has_active_requests(sender_node_id));
566566
#[cfg(lsps1_service)]
567567
let lsps1_has_active_requests = self
568568
.lsps1_service_handler
@@ -573,7 +573,7 @@ where
573573

574574
if !lsps5_service_handler.can_accept_request(
575575
sender_node_id,
576-
lsps2_has_opening_or_open_jit_channel,
576+
lsps2_has_active_requests,
577577
lsps1_has_active_requests,
578578
) {
579579
return Err(LightningError {

0 commit comments

Comments
 (0)