Skip to content

Commit 1f15f06

Browse files
fixup: Remove explicit timestamp and signature fields from SendWebhookNotification event.
They are provided in the headers field. Also the headers field is now a map instead of a vec since it's easier to handle with crates that do http requests
1 parent 1c67e50 commit 1f15f06

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
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;
@@ -143,7 +143,7 @@ pub enum LSPS5ServiceEvent {
143143
///
144144
/// When this event occurs, the LSP should:
145145
/// 1. Send an HTTP POST request to the specified webhook URL
146-
/// 2. Include all provided headers, especially the timestamp and signature headers
146+
/// 2. Include all provided headers in the request
147147
/// 3. Send the JSON-serialized notification as the request body
148148
/// 4. Handle any HTTP errors according to the LSP's retry policy
149149
///
@@ -181,22 +181,14 @@ pub enum LSPS5ServiceEvent {
181181
///
182182
/// This contains the type of notification and any associated data to be sent to the client.
183183
notification: WebhookNotification,
184-
/// Timestamp of the notification.
185-
///
186-
/// This timestamp is used for signing the notification and must be within 10 minutes
187-
/// of the client's local time for the signature to be accepted.
188-
timestamp: LSPSDateTime,
189-
/// Signature of the notification using the LSP's node ID.
190-
///
191-
/// This signature helps the client verify that the notification was sent by the LSP.
192-
signature: String,
193184
/// Headers to be included in the HTTP POST request.
194185
///
195-
/// Headers should include:
196-
/// - Content-Type (application/json)
197-
/// - x-lsps5-timestamp (timestamp in RFC3339 format, e.g., "YYYY-MM-DDThh:mm:ss.uuuZ")
198-
/// - x-lsps5-signature (signature of the notification using the LSP's node ID)
199-
headers: Vec<(String, String)>,
186+
/// This is a map of HTTP header key-value pairs. It will include:
187+
/// - `"Content-Type"`: with a value like `"application/json"`.
188+
/// - `"x-lsps5-timestamp"`: with the timestamp in RFC3339 format (`"YYYY-MM-DDThh:mm:ss.uuuZ"`).
189+
/// - `"x-lsps5-signature"`: with the signature of the notification payload, signed using the LSP's node ID.
190+
/// Other custom headers may also be included as needed.
191+
headers: HashMap<String, String>,
200192
},
201193
}
202194

lightning-liquidity/src/lsps5/service.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,19 +439,18 @@ where
439439

440440
let signature_hex = self.sign_notification(&notification, &timestamp);
441441

442-
let headers = vec![
443-
("Content-Type".to_string(), "application/json".to_string()),
444-
("x-lsps5-timestamp".to_string(), timestamp.to_rfc3339()),
445-
("x-lsps5-signature".to_string(), signature_hex.clone()),
446-
];
442+
let mut headers: HashMap<String, String> = [("Content-Type", "application/json")]
443+
.into_iter()
444+
.map(|(k, v)| (k.to_string(), v.to_string()))
445+
.collect();
446+
headers.insert("x-lsps5-timestamp".into(), timestamp.to_rfc3339());
447+
headers.insert("x-lsps5-signature".into(), signature_hex);
447448

448449
event_queue_notifier.enqueue(LSPS5ServiceEvent::SendWebhookNotification {
449450
counterparty_node_id,
450451
app_name,
451452
url,
452453
notification,
453-
timestamp,
454-
signature: signature_hex,
455454
headers,
456455
});
457456
}

0 commit comments

Comments
 (0)