pub struct LSPS5ServiceHandler<CM: Deref, NS: Deref, K: Deref + Clone, TP: Deref>where
CM::Target: AChannelManager,
NS::Target: NodeSigner,
K::Target: KVStore,
TP::Target: TimeProvider,{ /* private fields */ }Expand description
Service-side handler for the bLIP-55 / LSPS5 webhook registration protocol.
Runs on the LSP (server) side. Stores and manages client-registered webhooks, enforces per-client limits and retention policies, and emits signed JSON-RPC notifications to each webhook endpoint when events occur.
§Core Responsibilities
- Handle incoming JSON-RPC requests:
lsps5.set_webhook-> insert or replace a webhook, enforcemax_webhooks_per_client, and send an initiallsps5.webhook_registerednotification if new or changed.lsps5.list_webhooks-> return all registeredapp_names via response.lsps5.remove_webhook-> delete a named webhook or returnapp_name_not_founderror.
- Prune stale webhooks after a client has no open channels and no activity for at least
MIN_WEBHOOK_RETENTION_DAYS. - Sign and enqueue outgoing webhook notifications:
- Construct JSON-RPC 2.0 Notification objects
WebhookNotification, - Timestamp and LN-style zbase32-sign each payload,
- Emit
LSPS5ServiceEvent::SendWebhookNotificationwith HTTP headers.
- Construct JSON-RPC 2.0 Notification objects
§Security & Spec Compliance
- All notifications are signed with the LSP’s node key according to bLIP-50/LSPS0.
- Clients must validate signature, timestamp (±10 min), and replay protection via
LSPS5ClientHandler::parse_webhook_notification. - Webhook endpoints use only HTTPS and must guard against unauthorized calls.
Implementations§
Source§impl<CM: Deref, NS: Deref, K: Deref + Clone, TP: Deref> LSPS5ServiceHandler<CM, NS, K, TP>where
CM::Target: AChannelManager,
NS::Target: NodeSigner,
K::Target: KVStore,
TP::Target: TimeProvider,
impl<CM: Deref, NS: Deref, K: Deref + Clone, TP: Deref> LSPS5ServiceHandler<CM, NS, K, TP>where
CM::Target: AChannelManager,
NS::Target: NodeSigner,
K::Target: KVStore,
TP::Target: TimeProvider,
Sourcepub fn notify_payment_incoming(
&self,
client_id: PublicKey,
) -> Result<(), LSPS5ProtocolError>
pub fn notify_payment_incoming( &self, client_id: PublicKey, ) -> Result<(), LSPS5ProtocolError>
Notify the LSP service that the client has one or more incoming payments pending.
SHOULD be called by your LSP application logic as soon as you detect an incoming
payment (HTLC or future mechanism) for client_id.
This builds a WebhookNotificationMethod::LSPS5PaymentIncoming webhook notification, signs it with your
node key, and enqueues HTTP POSTs to all registered webhook URLs for that client.
This may fail if a similar notification was sent too recently,
violating the notification cooldown period defined in NOTIFICATION_COOLDOWN_TIME.
§Parameters
client_id: the client’s node-ID whose webhooks should be invoked.
Sourcepub fn notify_expiry_soon(
&self,
client_id: PublicKey,
timeout: u32,
) -> Result<(), LSPS5ProtocolError>
pub fn notify_expiry_soon( &self, client_id: PublicKey, timeout: u32, ) -> Result<(), LSPS5ProtocolError>
Notify that an HTLC or other time-bound contract is expiring soon.
SHOULD be called by your LSP application logic when a channel contract for client_id
is within 24 blocks of timeout, and the timeout would cause a channel closure.
Builds a WebhookNotificationMethod::LSPS5ExpirySoon notification including
the timeout block height, signs it, and enqueues HTTP POSTs to the client’s
registered webhooks.
This may fail if a similar notification was sent too recently,
violating the notification cooldown period defined in NOTIFICATION_COOLDOWN_TIME.
§Parameters
client_id: the client’s node-ID whose webhooks should be invoked.timeout: the block height at which the channel contract will expire.
Sourcepub fn notify_liquidity_management_request(
&self,
client_id: PublicKey,
) -> Result<(), LSPS5ProtocolError>
pub fn notify_liquidity_management_request( &self, client_id: PublicKey, ) -> Result<(), LSPS5ProtocolError>
Notify that the LSP intends to manage liquidity (e.g. close or splice) on client channels.
SHOULD be called by your LSP application logic when you decide to reclaim or adjust
liquidity for client_id. Builds a WebhookNotificationMethod::LSPS5LiquidityManagementRequest notification,
signs it, and sends it to all of the client’s registered webhook URLs.
This may fail if a similar notification was sent too recently,
violating the notification cooldown period defined in NOTIFICATION_COOLDOWN_TIME.
§Parameters
client_id: the client’s node-ID whose webhooks should be invoked.
Sourcepub fn notify_onion_message_incoming(
&self,
client_id: PublicKey,
) -> Result<(), LSPS5ProtocolError>
pub fn notify_onion_message_incoming( &self, client_id: PublicKey, ) -> Result<(), LSPS5ProtocolError>
Notify that the client has one or more pending BOLT Onion Messages.
SHOULD be called by your LSP application logic when you receive Onion Messages
for client_id while the client is offline. Builds a WebhookNotificationMethod::LSPS5OnionMessageIncoming
notification, signs it, and enqueues HTTP POSTs to each registered webhook.
This may fail if a similar notification was sent too recently,
violating the notification cooldown period defined in NOTIFICATION_COOLDOWN_TIME.
§Parameters
client_id: the client’s node-ID whose webhooks should be invoked.