Replace `insert_outbound_channel` with `PeerState::new_order`
What changed, and why it matters
This is a small internal code cleanup in the LSPS1 (liquidity service) module. It replaces a two-step process—creating a channel object in one file and inserting it in another—with a single method call. There is no user-visible behavior change and no security fix.
No security action needed. Treat as a normal refactoring commit during code review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors PeerState in lightning-liquidity/src/lsps1/peer_state.rs by removing the insert_outbound_channel method and adding new_order, which internally constructs an OutboundCRChannel and inserts it. The caller in service.rs is updated to use the new method, and the direct import of OutboundCRChannel is removed. The diff shows pure encapsulation/scope reduction with identical resulting state.
Changed components
lightning-liquidity/src/lsps1/peer_state.rslightning-liquidity/src/lsps1/service.rsInspect captured patch +9 / −6
diff --git a/lightning-liquidity/src/lsps1/peer_state.rs b/lightning-liquidity/src/lsps1/peer_state.rs
index 3e9d17f..729d682 100644
--- a/lightning-liquidity/src/lsps1/peer_state.rs
+++ b/lightning-liquidity/src/lsps1/peer_state.rs
@@ -21,9 +21,12 @@ pub(super) struct PeerState {
}
impl PeerState {
- pub(super) fn insert_outbound_channel(
- &mut self, order_id: LSPS1OrderId, channel: OutboundCRChannel,
+ pub(super) fn new_order(
+ &mut self, order_id: LSPS1OrderId, order_params: LSPS1OrderParams,
+ created_at: LSPSDateTime, payment_details: LSPS1PaymentInfo,
) {
+ let channel = OutboundCRChannel::new(order_params, created_at, payment_details);
+
self.outbound_channels_by_order_id.insert(order_id, channel);
}
}
diff --git a/lightning-liquidity/src/lsps1/service.rs b/lightning-liquidity/src/lsps1/service.rs
index df9d9f0..bda7d61 100644
--- a/lightning-liquidity/src/lsps1/service.rs
+++ b/lightning-liquidity/src/lsps1/service.rs
@@ -20,7 +20,7 @@ use super::msgs::{
LSPS1OrderState, LSPS1PaymentInfo, LSPS1Request, LSPS1Response,
LSPS1_CREATE_ORDER_REQUEST_ORDER_MISMATCH_ERROR_CODE,
};
-use super::peer_state::{OutboundCRChannel, PeerState};
+use super::peer_state::PeerState;
use crate::message_queue::MessageQueue;
use crate::events::EventQueue;
@@ -190,14 +190,14 @@ where
match peer_state_lock.pending_requests.remove(&request_id) {
Some(LSPS1Request::CreateOrder(params)) => {
let order_id = self.generate_order_id();
- let channel = OutboundCRChannel::new(
+
+ peer_state_lock.new_order(
+ order_id.clone(),
params.order.clone(),
created_at,
payment.clone(),
);
- peer_state_lock.insert_outbound_channel(order_id.clone(), channel);
-
let response = LSPS1Response::CreateOrder(LSPS1CreateOrderResponse {
order: params.order,
order_id,
Why this scored 15/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.