Drop bogus channel state handling
What changed, and why it matters
This commit removes unused, half-implemented state tracking code from an experimental LSPS1 (Lightning Service Provider Specification 1) liquidity module. The deleted code tracked whether an outbound channel order was 'created' or 'awaiting payment', but the commit message says the logic 'doesn't actually do anything' and will be replaced later. There is no direct evidence this fixes an active security bug; it appears to be a cleanup/refactoring change.
Treat as routine cleanup in an experimental feature. Monitor the promised follow-up commit that re-adds a 'proper state machine' to ensure the replacement logic correctly validates order/channel state transitions and prevents issues such as duplicate funding, refund abuse, or state desynchronization.
Security signals we found
Removal of incomplete state machine logic in a liquidity service module
Deletion of error-handling path that triggered refund event on state mismatch
No explicit security claim in commit message or diff
Evidence from the diff
The patch deletes OutboundRequestState, ChannelStateError, and the OutboundCRChannel::state field plus its awaiting_payment() transition. It also removes a state check in service.rs that would remove an order and emit a Refund event if the state machine rejected a GetOrder request. The commit message explicitly frames this as dropping ‘half-baked logic’ that is non-functional, to be re-implemented properly later. No replacement state machine is introduced.
Changed components
lightning-liquidity/src/lsps1/peer_state.rslightning-liquidity/src/lsps1/service.rsInspect captured patch +2 / −62
diff --git a/lightning-liquidity/src/lsps1/peer_state.rs b/lightning-liquidity/src/lsps1/peer_state.rs
index 71eeb66..3e9d17f 100644
--- a/lightning-liquidity/src/lsps1/peer_state.rs
+++ b/lightning-liquidity/src/lsps1/peer_state.rs
@@ -14,9 +14,6 @@ use super::msgs::{LSPS1OrderId, LSPS1OrderParams, LSPS1PaymentInfo, LSPS1Request
use crate::lsps0::ser::{LSPSDateTime, LSPSRequestId};
use crate::prelude::HashMap;
-use lightning::ln::msgs::{ErrorAction, LightningError};
-use lightning::util::logger::Level;
-
#[derive(Default)]
pub(super) struct PeerState {
pub(super) outbound_channels_by_order_id: HashMap<LSPS1OrderId, OutboundCRChannel>,
@@ -31,31 +28,6 @@ impl PeerState {
}
}
-struct ChannelStateError(String);
-
-impl From<ChannelStateError> for LightningError {
- fn from(value: ChannelStateError) -> Self {
- LightningError { err: value.0, action: ErrorAction::IgnoreAndLog(Level::Info) }
- }
-}
-
-#[derive(PartialEq, Debug)]
-pub(super) enum OutboundRequestState {
- OrderCreated { order_id: LSPS1OrderId },
- WaitingPayment { order_id: LSPS1OrderId },
-}
-
-impl OutboundRequestState {
- fn awaiting_payment(&self) -> Result<Self, ChannelStateError> {
- match self {
- OutboundRequestState::OrderCreated { order_id } => {
- Ok(OutboundRequestState::WaitingPayment { order_id: order_id.clone() })
- },
- state => Err(ChannelStateError(format!("TODO. JIT Channel was in state: {:?}", state))),
- }
- }
-}
-
pub(super) struct OutboundLSPS1Config {
pub(super) order: LSPS1OrderParams,
pub(super) created_at: LSPSDateTime,
@@ -63,22 +35,13 @@ pub(super) struct OutboundLSPS1Config {
}
pub(super) struct OutboundCRChannel {
- pub(super) state: OutboundRequestState,
pub(super) config: OutboundLSPS1Config,
}
impl OutboundCRChannel {
pub(super) fn new(
- order: LSPS1OrderParams, created_at: LSPSDateTime, order_id: LSPS1OrderId,
- payment: LSPS1PaymentInfo,
+ order: LSPS1OrderParams, created_at: LSPSDateTime, payment: LSPS1PaymentInfo,
) -> Self {
- Self {
- state: OutboundRequestState::OrderCreated { order_id },
- config: OutboundLSPS1Config { order, created_at, payment },
- }
- }
- pub(super) fn awaiting_payment(&mut self) -> Result<(), LightningError> {
- self.state = self.state.awaiting_payment()?;
- Ok(())
+ Self { config: OutboundLSPS1Config { order, created_at, payment } }
}
}
diff --git a/lightning-liquidity/src/lsps1/service.rs b/lightning-liquidity/src/lsps1/service.rs
index ac97b61..df9d9f0 100644
--- a/lightning-liquidity/src/lsps1/service.rs
+++ b/lightning-liquidity/src/lsps1/service.rs
@@ -193,7 +193,6 @@ where
let channel = OutboundCRChannel::new(
params.order.clone(),
created_at,
- order_id.clone(),
payment.clone(),
);
@@ -232,28 +231,6 @@ where
match outer_state_lock.get(counterparty_node_id) {
Some(inner_state_lock) => {
let mut peer_state_lock = inner_state_lock.lock().unwrap();
-
- let outbound_channel = peer_state_lock
- .outbound_channels_by_order_id
- .get_mut(¶ms.order_id)
- .ok_or(LightningError {
- err: format!(
- "Received get order request for unknown order id {:?}",
- params.order_id
- ),
- action: ErrorAction::IgnoreAndLog(Level::Info),
- })?;
-
- if let Err(e) = outbound_channel.awaiting_payment() {
- peer_state_lock.outbound_channels_by_order_id.remove(¶ms.order_id);
- event_queue_notifier.enqueue(LSPS1ServiceEvent::Refund {
- request_id,
- counterparty_node_id: *counterparty_node_id,
- order_id: params.order_id,
- });
- return Err(e);
- }
-
peer_state_lock
.pending_requests
.insert(request_id.clone(), LSPS1Request::GetOrder(params.clone()));
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.