@@ -457,7 +457,12 @@ where
457
457
if diff > ten_minutes {
458
458
return Err ( LSPS5ClientError :: InvalidTimestamp ( signature_timestamp. to_rfc3339 ( ) ) ) ;
459
459
}
460
-
460
+ println ! (
461
+ "LSPS5: Received notification from {} at {}" ,
462
+ counterparty_node_id,
463
+ signature_timestamp. to_rfc3339( )
464
+ ) ;
465
+ println ! ( "LSPS5: Notification: {:?}" , notification) ;
461
466
let message = format ! (
462
467
"LSPS5: DO NOT SIGN THIS MESSAGE MANUALLY: LSP: At {} I notify {:?}" ,
463
468
signature_timestamp. to_rfc3339( ) ,
@@ -519,16 +524,14 @@ where
519
524
/// - `counterparty_node_id`: the LSP’s public key, used to verify the signature.
520
525
/// - `timestamp`: ISO8601 time when the LSP created the notification.
521
526
/// - `signature`: the zbase32-encoded LN signature over timestamp+body.
522
- /// - `notification_json `: the JSON string of the JSON-RPC notification object .
527
+ /// - `notification `: the [`WebhookNotification`] received from the LSP .
523
528
///
524
- /// On success, emits [`LSPS5ClientEvent::WebhookNotificationReceived`]
525
- /// and returns the parsed [`WebhookNotification`].
529
+ /// On success, emits [`LSPS5ClientEvent::WebhookNotificationReceived`].
526
530
///
527
531
/// Failure reasons include:
528
532
/// - Timestamp too old (drift > 10 minutes)
529
533
/// - Replay attack detected (signature reused)
530
534
/// - Invalid signature (crypto check fails)
531
- /// - JSON parse errors for malformed `notification_json`
532
535
///
533
536
/// Clients should call this method upon receiving a [`LSPS5ServiceEvent::SendWebhookNotification`]
534
537
/// event, before taking action on the notification. This guarantees that only authentic,
@@ -539,30 +542,28 @@ where
539
542
/// [`WebhookNotification`]: super::msgs::WebhookNotification
540
543
pub fn parse_webhook_notification (
541
544
& self , counterparty_node_id : PublicKey , timestamp : & LSPSDateTime , signature : & str ,
542
- notification_json : & str ,
543
- ) -> Result < WebhookNotification , LSPS5ClientError > {
544
- let event_queue_notifier = self . pending_events . notifier ( ) ;
545
- let notification: WebhookNotification = serde_json:: from_str ( notification_json)
546
- . map_err ( |e| LSPS5ClientError :: DeserializeError ( e. to_string ( ) ) ) ?;
547
-
548
- self . check_signature_exists ( signature) ?;
549
-
550
- self . store_signature ( signature. to_string ( ) ) ;
551
-
545
+ notification : & WebhookNotification ,
546
+ ) -> Result < ( ) , LSPS5ClientError > {
552
547
match self . verify_notification_signature (
553
548
counterparty_node_id,
554
549
timestamp,
555
550
signature,
556
551
& notification,
557
552
) {
558
553
Ok ( signature_valid) => {
554
+ let event_queue_notifier = self . pending_events . notifier ( ) ;
555
+
556
+ self . check_signature_exists ( signature) ?;
557
+
558
+ self . store_signature ( signature. to_string ( ) ) ;
559
+
559
560
event_queue_notifier. enqueue ( LSPS5ClientEvent :: WebhookNotificationReceived {
560
561
counterparty_node_id,
561
562
notification : notification. clone ( ) ,
562
563
timestamp : timestamp. clone ( ) ,
563
564
signature_valid,
564
565
} ) ;
565
- Ok ( notification )
566
+ Ok ( ( ) )
566
567
} ,
567
568
Err ( e) => Err ( e) ,
568
569
}
0 commit comments