-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LSPS5 implementation #3662
base: main
Are you sure you want to change the base?
LSPS5 implementation #3662
Conversation
- Introduce LSPS5ServiceEvent for LSPS-side webhook events including registration, listing, removal, and notification. - Define LSPS5ClientEvent for handling webhook outcomes on the client (Lightning node) side. - Outline WebhookNotificationParams enum to support notification-specific parameters.
- Define LSPS5Request and LSPS5Response enums for webhook registration, listing, and removal. - Implement WebhookNotification and associated helper constructors for different notification types. - Implement serialization/deserialization support with comprehensive tests.
- Extend the match in TryFrom<LSPSMessage> to handle LSPSMessage::LSPS5 and explicitly return an error.
- Add clock feature to chrono for improved time handling. - Introduce reqwest with json and blocking features to support HTTP requests. - Add tokio with rt-multi-thread, time, sync, and macros features for asynchronous operations. These changes are used in LSPS modules to manage asynchronous network requests and accurate timing.
- Implement sign_notification to generate a recoverable ECDSA signature in lspsig format. - Format the message per LSPS5 specification and hash using SHA-256. - Serialize the signature with a recovery ID for signature verification. - Add tests to verify correct signature generation and key recovery.
- Introduce LSPS5ServiceHandler to manage webhook registration, listing, and removal. - Define LSPS5ServiceConfig for service settings including webhook limits, notification cooldown, and signature storage. - Integrate a custom HTTP client abstraction with a default reqwest-based implementation. - Leverage Tokio runtime for asynchronous delivery of webhook notifications. - Implement notification broadcasting with replay attack prevention and cooldown enforcement. - Emit events for webhook registration and notifications.
…ions - Introduce LSPS5ClientHandler to manage webhook operations (set, list, remove). - Implement enhanced URL validation and security checks. - Add per-peer state management with cleanup of expired requests. - Support verification of webhook notification signatures and parsing of notifications. - Include extensive tests to validate state isolation, request tracking, and response handling.
- Add client module to LSPS5 interface alongside event, msgs, service, and utils. - Define and document constants for maximum app name and webhook URL lengths.
- Update events.rs to include LSPS5 client and service event variants and From conversions. - Enhance lib.rs documentation to reference bLIP-55 / LSPS5 protocol support. - Modify manager.rs to initialize and route LSPS5 client and service handlers in LiquidityService. - Extend lsps0/ser.rs to support LSPS5 methods in LSPSMethod and LSPSMessage (de)serialization for SetWebhook, ListWebhooks, and RemoveWebhook.
- Add integration tests for LSPS5 covering: - Webhook registration flow with request ID matching. - Error handling for invalid URLs, app names, and protocol mismatches. - Notification delivery for different event types (payment_incoming, expiry_soon, liquidity_management_request). - Idempotency of webhook registrations and update detection. - Replay prevention, tampering, and out-of-window timestamp validations. - Extend LSPS2 integration tests to verify protocol message handling.
👋 I see @arik-so was un-assigned. |
This is a huge PR, but it wasn’t obvious to me how to split it in a way that would still make sense (I did split it into small commits to make it easier to review.). I’m open to suggestions if you have ideas on how this could be structured differently. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3662 +/- ##
==========================================
- Coverage 89.22% 89.12% -0.11%
==========================================
Files 155 159 +4
Lines 119327 120716 +1389
Branches 119327 120716 +1389
==========================================
+ Hits 106474 107588 +1114
- Misses 10247 10479 +232
- Partials 2606 2649 +43 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
A complete implementation for LSPS5 (spec defined here lightning/blips#55)
Reviewing commit by commit is recommended (~40% of the added lines are tests)