Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit ecfab31

Browse files
committed
Drop client-side channel state tracking
.. since it's aruably not needed now that we more and more decouple the fee-request and buy-request stages.
1 parent 6b42a38 commit ecfab31

File tree

1 file changed

+3
-47
lines changed

1 file changed

+3
-47
lines changed

src/lsps2/client.rs

+3-47
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use core::default::Default;
2727
use core::ops::Deref;
2828

2929
use crate::lsps2::msgs::{
30-
BuyRequest, BuyResponse, GetInfoRequest, GetInfoResponse, InterceptScid, LSPS2Message,
30+
BuyRequest, BuyResponse, GetInfoRequest, GetInfoResponse, LSPS2Message,
3131
LSPS2Request, LSPS2Response, OpeningFeeParams,
3232
};
3333

@@ -49,51 +49,13 @@ impl Default for LSPS2ClientConfig {
4949
}
5050
}
5151

52-
struct ChannelStateError(String);
53-
54-
impl From<ChannelStateError> for LightningError {
55-
fn from(value: ChannelStateError) -> Self {
56-
LightningError { err: value.0, action: ErrorAction::IgnoreAndLog(Level::Info) }
57-
}
58-
}
59-
60-
#[derive(PartialEq, Debug)]
61-
enum InboundJITChannelState {
62-
BuyRequested,
63-
PendingPayment { client_trusts_lsp: bool, intercept_scid: InterceptScid },
64-
}
65-
66-
impl InboundJITChannelState {
67-
fn invoice_params_received(
68-
&self, client_trusts_lsp: bool, intercept_scid: InterceptScid,
69-
) -> Result<Self, ChannelStateError> {
70-
match self {
71-
InboundJITChannelState::BuyRequested { .. } => {
72-
Ok(InboundJITChannelState::PendingPayment { client_trusts_lsp, intercept_scid })
73-
}
74-
state => Err(ChannelStateError(format!(
75-
"Invoice params received when JIT Channel was in state: {:?}",
76-
state
77-
))),
78-
}
79-
}
80-
}
81-
8252
struct InboundJITChannel {
83-
state: InboundJITChannelState,
8453
payment_size_msat: Option<u64>,
8554
}
8655

8756
impl InboundJITChannel {
8857
fn new(payment_size_msat: Option<u64>) -> Self {
89-
Self { payment_size_msat, state: InboundJITChannelState::BuyRequested }
90-
}
91-
92-
fn invoice_params_received(
93-
&mut self, client_trusts_lsp: bool, intercept_scid: InterceptScid,
94-
) -> Result<(), LightningError> {
95-
self.state = self.state.invoice_params_received(client_trusts_lsp, intercept_scid)?;
96-
Ok(())
58+
Self { payment_size_msat }
9759
}
9860
}
9961

@@ -305,7 +267,7 @@ where
305267
Some(inner_state_lock) => {
306268
let mut peer_state = inner_state_lock.lock().unwrap();
307269

308-
let mut jit_channel =
270+
let jit_channel =
309271
peer_state.pending_buy_requests.remove(&request_id).ok_or(LightningError {
310272
err: format!(
311273
"Received buy response for an unknown request: {:?}",
@@ -325,12 +287,6 @@ where
325287
});
326288
}
327289

328-
// Update the channel state
329-
jit_channel.invoice_params_received(
330-
result.client_trusts_lsp,
331-
result.intercept_scid.clone(),
332-
)?;
333-
334290
if let Ok(intercept_scid) = result.intercept_scid.to_scid() {
335291
self.pending_events.enqueue(Event::LSPS2Client(
336292
LSPS2ClientEvent::InvoiceParametersReady {

0 commit comments

Comments
 (0)