Skip to content

Commit 7d52499

Browse files
Add LSPS5 webhook service implementation
Implements the LSPS5 webhook registration service that allows LSPs to notify clients of important events via webhooks. This service handles webhook registration, listing, removal, and notification delivery according to the LSPS5 specification. Some details: - A generic HttpClient trait is defined so users can provide their own HTTP implementation - A generic TimeProvider trait is defined with a DefaultTimeProvider that uses std functionality - Uses URL utils to validate webhook URLs according to LSPS5 requirements - Uses secure message signing logic from the lightning::util::message_signing module - Works with the events and messages defined in earlier commits - Tests will be provided in a future commit
1 parent 253d8ea commit 7d52499

File tree

2 files changed

+516
-16
lines changed

2 files changed

+516
-16
lines changed

lightning-liquidity/src/lsps5/event.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
//! Contains bLIP-55 / LSPS5 event types
1111
12-
use crate::lsps0::ser::LSPSDateTime;
1312
use crate::lsps0::ser::LSPSRequestId;
1413
use alloc::string::String;
1514
use alloc::vec::Vec;
1615
use bitcoin::secp256k1::PublicKey;
16+
use lightning::util::hash_tables::HashMap;
1717

1818
use super::msgs::LSPS5AppName;
1919
use super::msgs::LSPS5Error;
@@ -31,7 +31,7 @@ pub enum LSPS5ServiceEvent {
3131
///
3232
/// When this event occurs, the LSP should:
3333
/// 1. Send an HTTP POST request to the specified webhook URL
34-
/// 2. Include all provided headers, especially the timestamp and signature headers
34+
/// 2. Include all provided headers in the request
3535
/// 3. Send the JSON-serialized notification as the request body
3636
/// 4. Handle any HTTP errors according to the LSP's retry policy
3737
///
@@ -69,22 +69,14 @@ pub enum LSPS5ServiceEvent {
6969
///
7070
/// This contains the type of notification and any associated data to be sent to the client.
7171
notification: WebhookNotification,
72-
/// Timestamp of the notification.
73-
///
74-
/// This timestamp is used for signing the notification and must be within 10 minutes
75-
/// of the client's local time for the signature to be accepted.
76-
timestamp: LSPSDateTime,
77-
/// Signature of the notification using the LSP's node ID.
78-
///
79-
/// This signature helps the client verify that the notification was sent by the LSP.
80-
signature: String,
8172
/// Headers to be included in the HTTP POST request.
8273
///
83-
/// Headers should include:
84-
/// - Content-Type (application/json)
85-
/// - x-lsps5-timestamp (timestamp in RFC3339 format, e.g., "YYYY-MM-DDThh:mm:ss.uuuZ")
86-
/// - x-lsps5-signature (signature of the notification using the LSP's node ID)
87-
headers: Vec<(String, String)>,
74+
/// This is a map of HTTP header key-value pairs. It will include:
75+
/// - `"Content-Type"`: with a value like `"application/json"`.
76+
/// - `"x-lsps5-timestamp"`: with the timestamp in RFC3339 format (`"YYYY-MM-DDThh:mm:ss.uuuZ"`).
77+
/// - `"x-lsps5-signature"`: with the signature of the notification payload, signed using the LSP's node ID.
78+
/// Other custom headers may also be included as needed.
79+
headers: HashMap<String, String>,
8880
},
8981
}
9082

0 commit comments

Comments
 (0)