LSPS5Validator

Struct LSPS5Validator 

Source
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

Source

pub fn new() -> Self

Create a new LSPS5Validator instance.

Source

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: The WebhookNotification received from the LSP.

Returns the validated WebhookNotification or an error for signature verification failure or replay attack.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.