Skip to content

Commit b522194

Browse files
fixup: accept lsps5 requests if lsps2 has an active request in any OutboundJITChannelState
1 parent cb66a95 commit b522194

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
@@ -566,20 +566,12 @@ where
566566
&self.config
567567
}
568568

569-
/// Returns whether the peer has any opening or open JIT channels.
570-
pub(crate) fn has_opening_or_open_jit_channel(&self, counterparty_node_id: &PublicKey) -> bool {
569+
/// Returns whether the peer has any active LSPS2 requests.
570+
pub(crate) fn has_active_requests(&self, counterparty_node_id: &PublicKey) -> bool {
571571
let outer_state_lock = self.per_peer_state.read().unwrap();
572572
outer_state_lock.get(counterparty_node_id).map_or(false, |inner| {
573573
let peer_state = inner.lock().unwrap();
574-
peer_state.outbound_channels_by_intercept_scid.values().any(|chan| {
575-
matches!(
576-
chan.state,
577-
OutboundJITChannelState::PendingChannelOpen { .. }
578-
| OutboundJITChannelState::PendingPaymentForward { .. }
579-
| OutboundJITChannelState::PendingPayment { .. }
580-
| OutboundJITChannelState::PaymentForwarded { .. }
581-
)
582-
})
574+
!peer_state.outbound_channels_by_intercept_scid.is_empty()
583575
})
584576
}
585577

lightning-liquidity/src/lsps5/service.rs

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

165162
fn check_prune_stale_webhooks<'a>(

lightning-liquidity/src/manager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,10 @@ where
568568
LSPSMessage::LSPS5(msg @ LSPS5Message::Request(..)) => {
569569
match &self.lsps5_service_handler {
570570
Some(lsps5_service_handler) => {
571-
let lsps2_has_opening_or_open_jit_channel = self
571+
let lsps2_has_active_requests = self
572572
.lsps2_service_handler
573573
.as_ref()
574-
.map_or(false, |h| h.has_opening_or_open_jit_channel(sender_node_id));
574+
.map_or(false, |h| h.has_active_requests(sender_node_id));
575575
#[cfg(lsps1_service)]
576576
let lsps1_has_active_requests = self
577577
.lsps1_service_handler
@@ -582,7 +582,7 @@ where
582582

583583
if !lsps5_service_handler.can_accept_request(
584584
sender_node_id,
585-
lsps2_has_opening_or_open_jit_channel,
585+
lsps2_has_active_requests,
586586
lsps1_has_active_requests,
587587
) {
588588
return Err(LightningError {

0 commit comments

Comments
 (0)