pub struct LSPS5Validator { /* private fields */ }Expand description
A utility for validating webhook notifications from an LSP.
In a typical setup, a proxy server receives webhook notifications from the LSP and then forwards them to the client (e.g., via mobile push notifications). This validator should be used by the proxy to verify the authenticity and integrity of the notification before processing or forwarding it.
§Core Capabilities
validate(...)-> Verifies signature, and protects against replay attacks.
The validator stores a small number of the most recently seen signatures
to protect against replays of the same notification.
Implementations§
Source§impl LSPS5Validator
impl LSPS5Validator
Sourcepub fn validate(
&self,
counterparty_node_id: PublicKey,
timestamp: &LSPSDateTime,
signature: &str,
notification: &WebhookNotification,
) -> Result<WebhookNotification, LSPS5ClientError>
pub fn validate( &self, counterparty_node_id: PublicKey, timestamp: &LSPSDateTime, signature: &str, notification: &WebhookNotification, ) -> Result<WebhookNotification, LSPS5ClientError>
Parse and validate a webhook notification received from an LSP.
Verifies the webhook delivery by verifying the zbase32 LN-style signature against the LSP’s node ID and ensuring that the signature is not a replay of a previously seen notification (within the last MAX_RECENT_SIGNATURES notifications).
Call this method on your proxy/server before processing any webhook notification to ensure its authenticity.
§Parameters
counterparty_node_id: The LSP’s public key, used to verify the signature.timestamp: ISO8601 time when the LSP created the notification.signature: The zbase32-encoded LN signature over timestamp+body.notification: TheWebhookNotificationreceived from the LSP.
Returns the validated WebhookNotification or an error for signature verification failure or replay attack.