Skip to content

Commit 1d41eef

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 1d41eef

File tree

3 files changed

+17
-265
lines changed

3 files changed

+17
-265
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: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ where
182182
&self, counterparty_node_id: PublicKey, request_id: LSPSRequestId,
183183
params: SetWebhookRequest,
184184
) -> Result<(), LightningError> {
185-
let event_queue_notifier = self.event_queue.notifier();
186185
self.check_prune_stale_webhooks();
187186

188187
let mut webhooks = self.webhooks.lock().unwrap();
@@ -228,19 +227,11 @@ where
228227

229228
client_webhooks.insert(params.app_name.clone(), stored_webhook);
230229

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-
239230
if !no_change {
240231
self.send_webhook_registered_notification(
241232
counterparty_node_id,
242-
params.app_name.clone(),
243-
params.webhook.clone(),
233+
params.app_name,
234+
params.webhook,
244235
);
245236
}
246237

@@ -261,7 +252,6 @@ where
261252
&self, counterparty_node_id: PublicKey, request_id: LSPSRequestId,
262253
_params: ListWebhooksRequest,
263254
) -> Result<(), LightningError> {
264-
let event_queue_notifier = self.event_queue.notifier();
265255
self.check_prune_stale_webhooks();
266256

267257
let webhooks = self.webhooks.lock().unwrap();
@@ -273,13 +263,6 @@ where
273263

274264
let max_webhooks = self.config.max_webhooks_per_client;
275265

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-
283266
let response = ListWebhooksResponse { app_names, max_webhooks };
284267
let msg = LSPS5Message::Response(request_id, LSPS5Response::ListWebhooks(response)).into();
285268
self.pending_messages.enqueue(&counterparty_node_id, msg);
@@ -291,25 +274,17 @@ where
291274
&self, counterparty_node_id: PublicKey, request_id: LSPSRequestId,
292275
params: RemoveWebhookRequest,
293276
) -> Result<(), LightningError> {
294-
let event_queue_notifier = self.event_queue.notifier();
295277
self.check_prune_stale_webhooks();
296278

297279
let mut webhooks = self.webhooks.lock().unwrap();
298280

299281
if let Some(client_webhooks) = webhooks.get_mut(&counterparty_node_id) {
300282
if client_webhooks.remove(&params.app_name).is_some() {
301283
let response = RemoveWebhookResponse {};
302-
let msg = LSPS5Message::Response(
303-
request_id.clone(),
304-
LSPS5Response::RemoveWebhook(response),
305-
)
306-
.into();
284+
let msg =
285+
LSPS5Message::Response(request_id, LSPS5Response::RemoveWebhook(response))
286+
.into();
307287
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-
});
313288

314289
return Ok(());
315290
}

0 commit comments

Comments
 (0)