Skip to content

Commit e5d120a

Browse files
fixup: Drop service set / list / remove events.
Service will no longer notify the user when it sets / lists / removes. It will only notify when the user needs to do an HTTP call via SendWebhookNotification event
1 parent 262b404 commit e5d120a

File tree

3 files changed

+20
-274
lines changed

3 files changed

+20
-274
lines changed

lightning-liquidity/src/lsps5/event.rs

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -23,118 +23,6 @@ use super::msgs::WebhookNotification;
2323
/// An event which an bLIP-55 / LSPS5 server should take some action in response to.
2424
#[derive(Debug, Clone, PartialEq, Eq)]
2525
pub enum LSPS5ServiceEvent {
26-
/// A webhook was registered by a client.
27-
///
28-
/// This event is triggered when a client successfully registers or updates a webhook
29-
/// via [`lsps5.set_webhook`]. The LSP should store this webhook information for future
30-
/// notifications to this client.
31-
///
32-
/// When this event occurs, the LSP should:
33-
/// 1. Store the webhook information for the client
34-
/// 2. If `no_change` is `false` (i.e., this is a new registration or an update with changes),
35-
/// send an initial [`lsps5.webhook_registered`] notification to verify the webhook works.
36-
///
37-
/// [`lsps5.set_webhook`]: super::msgs::LSPS5Request::SetWebhook
38-
/// [`lsps5.webhook_registered`]: super::msgs::WebhookNotificationMethod::LSPS5WebhookRegistered
39-
WebhookRegistered {
40-
/// Client node ID that registered the webhook.
41-
counterparty_node_id: PublicKey,
42-
/// App name provided by the client.
43-
///
44-
/// This app name is used to identify the webhook registration.
45-
///
46-
/// **Note**: Ensure the app name is valid and its length does not exceed [`MAX_APP_NAME_LENGTH`].
47-
///
48-
/// [`MAX_APP_NAME_LENGTH`]: super::msgs::MAX_APP_NAME_LENGTH
49-
app_name: LSPS5AppName,
50-
/// Webhook URL (HTTPS) to be contacted for notifying the client.
51-
///
52-
/// This URL is used by the LSP to send notifications.
53-
///
54-
/// **Note**: Ensure the URL is valid and its length does not exceed [`MAX_WEBHOOK_URL_LENGTH`].
55-
/// Also ensure that the URL points to a public host.
56-
///
57-
/// [`MAX_WEBHOOK_URL_LENGTH`]: super::msgs::MAX_WEBHOOK_URL_LENGTH
58-
url: LSPS5WebhookUrl,
59-
/// The identifier of the issued bLIP-55 / LSPS5 webhook registration request.
60-
///
61-
/// This can be used to track which request this event corresponds to.
62-
request_id: LSPSRequestId,
63-
/// Whether this was a new registration or an update to existing one with no changes.
64-
/// If false, a notification should be sent to the registered webhook.
65-
no_change: bool,
66-
},
67-
68-
/// Webhooks were listed for a client.
69-
///
70-
/// This event is triggered when a client successfully requests their registered webhooks
71-
/// via [`lsps5.list_webhooks`]. The LSP has responded with the list of app names that
72-
/// have registered webhooks for this client.
73-
///
74-
/// When this event occurs, it indicates that:
75-
/// 1. The LSP has successfully fetched all registered webhook names for this client
76-
/// 2. The LSP has sent a response containing the list and maximum allowed webhooks
77-
/// 3. The client is now aware of all their currently registered webhooks
78-
///
79-
/// This event is primarily informational and doesn't typically require further action.
80-
///
81-
/// [`lsps5.list_webhooks`]: super::msgs::LSPS5Request::ListWebhooks
82-
WebhooksListed {
83-
/// Client node ID that requested their webhooks.
84-
counterparty_node_id: PublicKey,
85-
/// App names with registered webhooks for this client.
86-
///
87-
/// Each [`app_name`] in this list corresponds to a registered webhook.
88-
///
89-
/// [`app_name`]: super::msgs::LSPS5AppName
90-
app_names: Vec<LSPS5AppName>,
91-
/// The identifier of the issued bLIP-55 / LSPS5 webhook listing request.
92-
///
93-
/// This can be used to track which request this event corresponds to.
94-
request_id: LSPSRequestId,
95-
/// Maximum number of webhooks allowed by LSP per client.
96-
///
97-
/// This is the value defined in [`max_webhooks_per_client`] within the service configuration.
98-
///
99-
/// [`max_webhooks_per_client`]: super::service::LSPS5ServiceConfig::max_webhooks_per_client
100-
max_webhooks: u32,
101-
},
102-
103-
/// A webhook was removed by a client.
104-
///
105-
/// This event is triggered when a client successfully removes a webhook via
106-
/// [`lsps5.remove_webhook`]. The LSP has deleted the specified webhook registration from
107-
/// its storage and will no longer send notifications to this webhook URL.
108-
///
109-
/// When this event occurs, the LSP should:
110-
/// 1. Confirm the webhook has been completely removed from all internal data structures
111-
/// 2. If there are any pending notifications for this webhook, cancel them
112-
/// 3. Update any related metrics or logs to reflect the webhook removal
113-
///
114-
/// Note that if a client attempts to remove a webhook that doesn't exist, a
115-
/// [`LSPS5ProtocolError::AppNameNotFound`] error is returned instead, and this event
116-
/// will not be triggered.
117-
///
118-
/// [`lsps5.remove_webhook`]: super::msgs::LSPS5Request::RemoveWebhook
119-
/// [`LSPS5ProtocolError::AppNameNotFound`]: super::msgs::LSPS5ProtocolError::AppNameNotFound
120-
WebhookRemoved {
121-
/// Client node ID that removed the webhook.
122-
counterparty_node_id: PublicKey,
123-
/// App name that was removed.
124-
///
125-
/// This identifies the webhook that was removed.
126-
///
127-
/// **Note**: The [`app_name`] must have been previously registered via [`lsps5.set_webhook`].
128-
///
129-
/// [`app_name`]: super::msgs::LSPS5AppName
130-
/// [`lsps5.set_webhook`]: super::msgs::LSPS5Request::SetWebhook
131-
app_name: LSPS5AppName,
132-
/// The identifier of the issued bLIP-55 / LSPS5 webhook removal request.
133-
///
134-
/// This can be used to track which request this event corresponds to.
135-
request_id: LSPSRequestId,
136-
},
137-
13826
/// A notification needs to be sent to a client's webhook.
13927
///
14028
/// This event is triggered when the LSP needs to notify a client about an event

lightning-liquidity/src/lsps5/service.rs

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,9 @@ pub struct LSPS5ServiceConfig {
9595
/// # Core Responsibilities
9696
/// - Handle incoming JSON-RPC requests:
9797
/// - `lsps5.set_webhook` -> insert or replace a webhook, enforce [`max_webhooks_per_client`],
98-
/// emit [`LSPS5ServiceEvent::WebhookRegistered`], and send an initial
99-
/// [`lsps5.webhook_registered`] notification if new or changed.
100-
/// - `lsps5.list_webhooks` -> return all registered [`app_name`]s via response and
101-
/// [`LSPS5ServiceEvent::WebhooksListed`].
102-
/// - `lsps5.remove_webhook` -> delete a named webhook or return [`app_name_not_found`]
103-
/// error, emitting [`LSPS5ServiceEvent::WebhookRemoved`].
98+
/// and send an initial [`lsps5.webhook_registered`] notification if new or changed.
99+
/// - `lsps5.list_webhooks` -> return all registered [`app_name`]s via response.
100+
/// - `lsps5.remove_webhook` -> delete a named webhook or return [`app_name_not_found`] error.
104101
/// - Prune stale webhooks after a client has no open channels and no activity for at least
105102
/// [`MIN_WEBHOOK_RETENTION_DAYS`].
106103
/// - Rate-limit repeat notifications of the same method to a client by
@@ -118,9 +115,6 @@ pub struct LSPS5ServiceConfig {
118115
///
119116
/// [`bLIP-55 / LSPS5`]: https://github.com/lightning/blips/pull/55/files
120117
/// [`max_webhooks_per_client`]: super::service::LSPS5ServiceConfig::max_webhooks_per_client
121-
/// [`LSPS5ServiceEvent::WebhookRegistered`]: super::event::LSPS5ServiceEvent::WebhookRegistered
122-
/// [`LSPS5ServiceEvent::WebhooksListed`]: super::event::LSPS5ServiceEvent::WebhooksListed
123-
/// [`LSPS5ServiceEvent::WebhookRemoved`]: super::event::LSPS5ServiceEvent::WebhookRemoved
124118
/// [`app_name_not_found`]: super::msgs::LSPS5ProtocolError::AppNameNotFound
125119
/// [`notification_cooldown_hours`]: super::service::LSPS5ServiceConfig::notification_cooldown_hours
126120
/// [`WebhookNotification`]: super::msgs::WebhookNotification
@@ -182,7 +176,6 @@ where
182176
&self, counterparty_node_id: PublicKey, request_id: LSPSRequestId,
183177
params: SetWebhookRequest,
184178
) -> Result<(), LightningError> {
185-
let event_queue_notifier = self.event_queue.notifier();
186179
self.check_prune_stale_webhooks();
187180

188181
let mut webhooks = self.webhooks.lock().unwrap();
@@ -228,19 +221,11 @@ where
228221

229222
client_webhooks.insert(params.app_name.clone(), stored_webhook);
230223

231-
event_queue_notifier.enqueue(LSPS5ServiceEvent::WebhookRegistered {
232-
counterparty_node_id,
233-
app_name: params.app_name.clone(),
234-
url: params.webhook.clone(),
235-
request_id: request_id.clone(),
236-
no_change,
237-
});
238-
239224
if !no_change {
240225
self.send_webhook_registered_notification(
241226
counterparty_node_id,
242-
params.app_name.clone(),
243-
params.webhook.clone(),
227+
params.app_name,
228+
params.webhook,
244229
);
245230
}
246231

@@ -261,7 +246,6 @@ where
261246
&self, counterparty_node_id: PublicKey, request_id: LSPSRequestId,
262247
_params: ListWebhooksRequest,
263248
) -> Result<(), LightningError> {
264-
let event_queue_notifier = self.event_queue.notifier();
265249
self.check_prune_stale_webhooks();
266250

267251
let webhooks = self.webhooks.lock().unwrap();
@@ -273,13 +257,6 @@ where
273257

274258
let max_webhooks = self.config.max_webhooks_per_client;
275259

276-
event_queue_notifier.enqueue(LSPS5ServiceEvent::WebhooksListed {
277-
counterparty_node_id,
278-
app_names: app_names.clone(),
279-
max_webhooks,
280-
request_id: request_id.clone(),
281-
});
282-
283260
let response = ListWebhooksResponse { app_names, max_webhooks };
284261
let msg = LSPS5Message::Response(request_id, LSPS5Response::ListWebhooks(response)).into();
285262
self.pending_messages.enqueue(&counterparty_node_id, msg);
@@ -291,25 +268,17 @@ where
291268
&self, counterparty_node_id: PublicKey, request_id: LSPSRequestId,
292269
params: RemoveWebhookRequest,
293270
) -> Result<(), LightningError> {
294-
let event_queue_notifier = self.event_queue.notifier();
295271
self.check_prune_stale_webhooks();
296272

297273
let mut webhooks = self.webhooks.lock().unwrap();
298274

299275
if let Some(client_webhooks) = webhooks.get_mut(&counterparty_node_id) {
300276
if client_webhooks.remove(&params.app_name).is_some() {
301277
let response = RemoveWebhookResponse {};
302-
let msg = LSPS5Message::Response(
303-
request_id.clone(),
304-
LSPS5Response::RemoveWebhook(response),
305-
)
306-
.into();
278+
let msg =
279+
LSPS5Message::Response(request_id, LSPS5Response::RemoveWebhook(response))
280+
.into();
307281
self.pending_messages.enqueue(&counterparty_node_id, msg);
308-
event_queue_notifier.enqueue(LSPS5ServiceEvent::WebhookRemoved {
309-
counterparty_node_id,
310-
app_name: params.app_name,
311-
request_id,
312-
});
313282

314283
return Ok(());
315284
}

0 commit comments

Comments
 (0)