Skip to content

Commit 222b933

Browse files
fixup: cleanup events documentation. condense and remove lots of noise and unnecesary docs
1 parent 43a2d2f commit 222b933

File tree

1 file changed

+27
-99
lines changed

1 file changed

+27
-99
lines changed

lightning-liquidity/src/lsps5/event.rs

Lines changed: 27 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,37 @@ 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 notification needs to be sent to a client's webhook.
26+
/// A notification needs to be sent to a client.
2727
///
2828
/// This event is triggered when the LSP needs to notify a client about an event
29-
/// via their registered webhook. The LSP must make an HTTP POST request to the
30-
/// provided URL with the specified headers and notification content.
29+
/// via their registered webhook.
3130
///
32-
/// When this event occurs, the LSP should:
33-
/// 1. Send an HTTP POST request to the specified webhook URL
34-
/// 2. Include all provided headers in the request
35-
/// 3. Send the JSON-serialized notification as the request body
36-
/// 4. Handle any HTTP errors according to the LSP's retry policy
31+
/// When this event occurs, the LSP should send an HTTP POST request to
32+
/// the provided webhook URL with the given headers and notification.
33+
/// If the HTTP request fails, the LSP may implement a retry policy according to its
34+
/// implementation preferences, but must respect rate-limiting as defined in
35+
/// [`notification_cooldown_hours`].
3736
///
3837
/// The notification is signed using the LSP's node ID to ensure authenticity
3938
/// when received by the client. The client verifies this signature using
4039
/// [`parse_webhook_notification`], which guards against replay attacks and tampering.
4140
///
42-
/// If the HTTP request fails, the LSP may implement a retry policy according to its
43-
/// implementation preferences, but must respect rate-limiting as defined in
44-
/// [`notification_cooldown_hours`].
45-
///
4641
/// [`parse_webhook_notification`]: super::client::LSPS5ClientHandler::parse_webhook_notification
4742
/// [`notification_cooldown_hours`]: super::service::LSPS5ServiceConfig::notification_cooldown_hours
4843
SendWebhookNotification {
4944
/// Client node ID to be notified.
5045
counterparty_node_id: PublicKey,
51-
/// App name to be notified.
46+
/// [`App name`] to be notified.
5247
///
5348
/// This identifies which webhook registration should be notified.
5449
///
55-
/// **Note**: The [`app_name`] must have been previously registered via [`lsps5.set_webhook`].
56-
///
57-
/// [`app_name`]: super::msgs::LSPS5AppName
58-
/// [`lsps5.set_webhook`]: super::msgs::LSPS5Request::SetWebhook
50+
/// [`App name`]: super::msgs::LSPS5AppName
5951
app_name: LSPS5AppName,
60-
/// URL that to be contacted.
61-
///
62-
/// This is the webhook URL (HTTPS) provided by the client during registration.
52+
/// URL to be called.
6353
///
64-
/// **Note**: The URL must be a valid HTTPS URL that points to a public host.
54+
/// This is the [`webhook URL`] provided by the client during registration.
6555
///
66-
/// [`url`]: super::msgs::LSPS5WebhookUrl
56+
/// [`webhook URL`]: super::msgs::LSPS5WebhookUrl
6757
url: LSPS5WebhookUrl,
6858
/// Notification method with its parameters.
6959
///
@@ -86,24 +76,15 @@ pub enum LSPS5ClientEvent {
8676
/// A webhook was successfully registered with the LSP.
8777
///
8878
/// This event is triggered when the LSP confirms successful registration
89-
/// of a webhook via [`lsps5.set_webhook`]. The client has received a successful
90-
/// response with information about the total number of webhooks registered and limits.
79+
/// of a webhook via [`lsps5.set_webhook`].
9180
///
92-
/// When this event occurs, the client should:
93-
/// 1. Update any UI to reflect the successful registration
94-
/// 2. Store the webhook registration details if needed locally
95-
/// 3. Prepare to receive notifications at the registered webhook URL
96-
/// 4. Note that if `no_change` is `true`, the LSP did not send a test notification
97-
///
98-
/// The [`app_name`] and [`url`] both must respect maximum lengths of
99-
/// [`MAX_APP_NAME_LENGTH`] and [`MAX_WEBHOOK_URL_LENGTH`] respectively, and the
100-
/// [`url`] must use HTTPS.
81+
/// If `no_change` is `false` (indicating the registered webhook is a new registration),
82+
/// the LSP will also emit a [`SendWebhookNotification`] event with a [`webhook_registered`] notification
83+
/// to notify the client about this registration.
10184
///
10285
/// [`lsps5.set_webhook`]: super::msgs::LSPS5Request::SetWebhook
103-
/// [`app_name`]: super::msgs::LSPS5AppName
104-
/// [`url`]: super::msgs::LSPS5WebhookUrl
105-
/// [`MAX_APP_NAME_LENGTH`]: super::msgs::MAX_APP_NAME_LENGTH
106-
/// [`MAX_WEBHOOK_URL_LENGTH`]: super::msgs::MAX_WEBHOOK_URL_LENGTH
86+
/// [`SendWebhookNotification`]: super::event::LSPS5ServiceEvent::SendWebhookNotification
87+
/// [`webhook_registered`]: super::msgs::WebhookNotificationMethod::LSPS5WebhookRegistered
10788
WebhookRegistered {
10889
/// The node id of the LSP that confirmed the registration.
10990
counterparty_node_id: PublicKey,
@@ -127,19 +108,14 @@ pub enum LSPS5ClientEvent {
127108
/// A webhook registration attempt failed.
128109
///
129110
/// This event is triggered when the LSP rejects a webhook registration
130-
/// via [`lsps5.set_webhook`]. This failure can occur for several reasons:
131-
///
132-
/// When this event occurs, the client should:
133-
/// 1. Present an appropriate error message to the user
134-
/// 2. Consider retry strategies based on the specific error
135-
/// 3. If the error is due to reaching webhook limits, prompt the user to remove
136-
/// unused webhooks before trying again
111+
/// via [`lsps5.set_webhook`].
137112
///
138-
/// Common error cases include:
139-
/// - The [`app_name`] exceeds [`MAX_APP_NAME_LENGTH`] (error [`AppNameTooLong`])
140-
/// - The [`url`] exceeds [`MAX_WEBHOOK_URL_LENGTH`] (error [`WebhookUrlTooLong`])
141-
/// - The [`url`] uses an unsupported protocol; HTTPS is required (error [`UnsupportedProtocol`])
142-
/// - Maximum number of webhooks per client has been reached (error [`TooManyWebhooks`])
113+
/// Possible errors:
114+
/// - The [`app_name`] exceeds [`MAX_APP_NAME_LENGTH`] (error [`AppNameTooLong`]).
115+
/// - The [`url`] exceeds [`MAX_WEBHOOK_URL_LENGTH`] (error [`WebhookUrlTooLong`]).
116+
/// - The [`url`] uses an unsupported protocol. HTTPS is required (error [`UnsupportedProtocol`]).
117+
/// - Maximum number of webhooks per client has been reached (error [`TooManyWebhooks`]). Remove a webhook before
118+
/// registering a new one.
143119
///
144120
/// [`lsps5.set_webhook`]: super::msgs::LSPS5Request::SetWebhook
145121
/// [`app_name`]: super::msgs::LSPS5AppName
@@ -168,16 +144,7 @@ pub enum LSPS5ClientEvent {
168144
/// The list of registered webhooks was successfully retrieved.
169145
///
170146
/// This event is triggered when the LSP responds to a
171-
/// [`lsps5.list_webhooks`] request. The client now has an up-to-date
172-
/// list of all registered webhook app names.
173-
///
174-
/// When this event occurs, the client should:
175-
/// 1. Update any UI to display the list of registered webhooks
176-
/// 2. Update any local cache or state about registered webhooks
177-
/// 3. Check if the number of webhooks approaches the maximum allowed limit
178-
///
179-
/// This listing only provides the app names; to get the URLs, the client would
180-
/// need to maintain its own records from registration events.
147+
/// [`lsps5.list_webhooks`] request.
181148
///
182149
/// [`lsps5.list_webhooks`]: super::msgs::LSPS5Request::ListWebhooks
183150
WebhooksListed {
@@ -193,44 +160,13 @@ pub enum LSPS5ClientEvent {
193160
request_id: LSPSRequestId,
194161
},
195162

196-
/// The attempt to list webhooks failed.
197-
///
198-
/// This event is triggered when the LSP rejects a
199-
/// [`lsps5.list_webhooks`] request. This is uncommon but might occur
200-
/// due to temporary server issues or authentication problems.
201-
///
202-
/// When this event occurs, the client should:
203-
/// 1. Present an appropriate error message to the user
204-
/// 2. Consider implementing a retry mechanism with backoff
205-
/// 3. If persistent, check connectivity to the LSP node
206-
///
207-
/// The error details provided can help diagnose the specific issue.
208-
///
209-
/// [`lsps5.list_webhooks`]: super::msgs::LSPS5Request::ListWebhooks
210-
WebhooksListFailed {
211-
/// The node id of the LSP that rejected the request.
212-
counterparty_node_id: PublicKey,
213-
/// Error from the LSP.
214-
error: LSPS5Error,
215-
/// The identifier of the issued bLIP-55 / LSPS5 list webhooks request.
216-
///
217-
/// This can be used to track which request this event corresponds to.
218-
request_id: LSPSRequestId,
219-
},
220-
221163
/// A webhook was successfully removed.
222164
///
223165
/// This event is triggered when the LSP confirms successful removal
224166
/// of a webhook via [`lsps5.remove_webhook`]. The webhook registration
225167
/// has been deleted from the LSP's system and will no longer receive
226168
/// notifications.
227169
///
228-
/// When this event occurs, the client should:
229-
/// 1. Update any UI to reflect the webhook removal
230-
/// 2. Remove the webhook from any local storage or cache
231-
/// 3. Update counters or indicators showing the number of registered webhooks
232-
/// 4. Take any application-specific cleanup actions for the removed webhook
233-
///
234170
/// After this event, the app_name is free to be reused for a new webhook
235171
/// registration if desired.
236172
///
@@ -249,15 +185,7 @@ pub enum LSPS5ClientEvent {
249185
/// A webhook removal attempt failed.
250186
///
251187
/// This event is triggered when the LSP rejects a webhook removal
252-
/// via [`lsps5.remove_webhook`]. The most common scenario is attempting
253-
/// to remove a webhook that doesn't exist or was already removed.
254-
///
255-
/// When this event occurs, the client should:
256-
/// 1. Present an appropriate error message to the user
257-
/// 2. If the error is [`AppNameNotFound`], update any local state to
258-
/// reflect that the webhook does not exist on the server
259-
/// 3. Consider refreshing the webhook list to ensure local state
260-
/// matches server state
188+
/// via [`lsps5.remove_webhook`].
261189
///
262190
/// The most common error is [`LSPS5ProtocolError::AppNameNotFound`]
263191
/// (error code [`LSPS5_APP_NAME_NOT_FOUND_ERROR_CODE`]), which indicates

0 commit comments

Comments
 (0)