Add a trivial helper to LSPS5's `WebhookNotification`
What changed, and why it matters
This commit adds a small convenience helper that converts an LSPS5 webhook notification into a JSON string. It is purely a developer-experience improvement and does not change any security behavior.
No security action required. Review as normal code quality/API ergonomics change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces WebhookNotification::to_request_body(), which wraps serde_json::to_string(self).unwrap() to produce the JSON body for HTTP webhook delivery. The existing docs are updated to reference this helper. There are no changes to serialization logic, signature handling, network behavior, or trust boundaries.
Changed components
lightning-liquidity/src/lsps5/msgs.rslightning-liquidity/src/lsps5/event.rsInspect captured patch +9 / −3
diff --git a/lightning-liquidity/src/lsps5/event.rs b/lightning-liquidity/src/lsps5/event.rs
index c122738..30e3aea 100644
--- a/lightning-liquidity/src/lsps5/event.rs
+++ b/lightning-liquidity/src/lsps5/event.rs
@@ -30,9 +30,9 @@ pub enum LSPS5ServiceEvent {
/// via their registered webhook.
///
/// The LSP should send an HTTP POST to the [`url`], using the
- /// JSON-serialized [`notification`] as the body and including the `headers`.
- /// If the HTTP request fails, the LSP may implement a retry policy according to its
- /// implementation preferences.
+ /// JSON-serialized [`notification`] (via [`WebhookNotification::to_request_body`]) as the body
+ /// and including the `headers`. If the HTTP request fails, the LSP may implement a retry
+ /// policy according to its implementation preferences.
///
/// The notification is signed using the LSP's node ID to ensure authenticity
/// when received by the client. The client verifies this signature using
diff --git a/lightning-liquidity/src/lsps5/msgs.rs b/lightning-liquidity/src/lsps5/msgs.rs
index e457c29..363a325 100644
--- a/lightning-liquidity/src/lsps5/msgs.rs
+++ b/lightning-liquidity/src/lsps5/msgs.rs
@@ -565,6 +565,12 @@ impl WebhookNotification {
pub fn onion_message_incoming() -> Self {
Self { method: WebhookNotificationMethod::LSPS5OnionMessageIncoming }
}
+
+ /// Encodes this notification into JSON which can be sent as the body of an HTTP request to
+ /// deliver the notification.
+ pub fn to_request_body(&self) -> String {
+ serde_json::to_string(self).unwrap()
+ }
}
impl Serialize for WebhookNotification {
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.