Skip to content

Commit 3ce2a63

Browse files
fixup: implement debug for WebhookNotification for consistent formatting when signing notification
1 parent 69d5a72 commit 3ce2a63

File tree

1 file changed

+12
-1
lines changed
  • lightning-liquidity/src/lsps5

1 file changed

+12
-1
lines changed

lightning-liquidity/src/lsps5/msgs.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ pub enum WebhookNotificationMethod {
461461
}
462462

463463
/// Webhook notification payload.
464-
#[derive(Debug, Clone, PartialEq, Eq)]
464+
#[derive(Clone, PartialEq, Eq)]
465465
pub struct WebhookNotification {
466466
/// Notification method with parameters.
467467
pub method: WebhookNotificationMethod,
@@ -499,6 +499,17 @@ impl WebhookNotification {
499499
}
500500
}
501501

502+
impl fmt::Debug for WebhookNotification {
503+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
504+
match serde_json::to_string(self) {
505+
Ok(json) => f.write_str(&json),
506+
// WebhookNotification is well defined and does not contain arbitrary data, so
507+
// this case should never happen.
508+
Err(_) => f.write_str("<failed-to-serialize>"),
509+
}
510+
}
511+
}
512+
502513
impl Serialize for WebhookNotification {
503514
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
504515
where

0 commit comments

Comments
 (0)