Log `PublicKey`s as `Display`, not `Debug`
What changed, and why it matters
This commit changes how public keys appear in log and error messages. Previously they were logged using Rust's Debug format, which prints raw byte arrays. Now they use the Display format, which prints the standard readable string form of a public key. This is a code-quality and readability improvement; it does not fix a security vulnerability and does not change program behavior beyond log formatting.
No security action required. Treat as a normal code-quality/logging improvement.
Security signals we found
No security-relevant behavior change
Log formatting only
No input validation, cryptography, or memory-safety changes
Evidence from the diff
The patch replaces {:?} (Debug) with {} (Display) for PublicKey values in format strings across the lightning-liquidity crate. In Rust, bitcoin::PublicKey and secp256k1::PublicKey implement Display as a hex-compressed string and Debug as a structured byte dump. The change makes logs consistent and easier to read, and removes unnecessary parentheses around some format arguments. There is no functional change to message handling, state machines, or cryptographic operations.
Changed components
lightning-liquidity/src/lsps0/client.rslightning-liquidity/src/lsps0/service.rslightning-liquidity/src/lsps1/client.rslightning-liquidity/src/lsps2/client.rslightning-liquidity/src/lsps2/service.rslightning-liquidity/src/lsps5/service.rslightning-liquidity/src/manager.rsInspect captured patch +29 / −26
diff --git a/lightning-liquidity/src/lsps0/client.rs b/lightning-liquidity/src/lsps0/client.rs
index 7f26d74..d300936 100644
--- a/lightning-liquidity/src/lsps0/client.rs
+++ b/lightning-liquidity/src/lsps0/client.rs
@@ -109,7 +109,7 @@ where
false,
"Client handler received LSPS0 request message. This should never happen."
);
- Err(LightningError { err: format!("Client handler received LSPS0 request message from node {:?}. This should never happen.", counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)})
+ Err(LightningError { err: format!("Client handler received LSPS0 request message from node {}. This should never happen.", counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)})
},
}
}
diff --git a/lightning-liquidity/src/lsps0/service.rs b/lightning-liquidity/src/lsps0/service.rs
index e71150c..f341076 100644
--- a/lightning-liquidity/src/lsps0/service.rs
+++ b/lightning-liquidity/src/lsps0/service.rs
@@ -73,7 +73,7 @@ impl LSPSProtocolMessageHandler for LSPS0ServiceHandler {
false,
"Service handler received LSPS0 response message. This should never happen."
);
- Err(LightningError { err: format!("Service handler received LSPS0 response message from node {:?}. This should never happen.", counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)})
+ Err(LightningError { err: format!("Service handler received LSPS0 response message from node {}. This should never happen.", counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)})
},
}
}
diff --git a/lightning-liquidity/src/lsps1/client.rs b/lightning-liquidity/src/lsps1/client.rs
index 5b9d373..4a79fb6 100644
--- a/lightning-liquidity/src/lsps1/client.rs
+++ b/lightning-liquidity/src/lsps1/client.rs
@@ -141,7 +141,7 @@ where
},
None => Err(LightningError {
err: format!(
- "Received get_info response from unknown peer: {:?}",
+ "Received get_info response from unknown peer: {}",
counterparty_node_id
),
action: ErrorAction::IgnoreAndLog(Level::Debug),
@@ -187,7 +187,7 @@ where
None => {
return Err(LightningError {
err: format!(
- "Received get_info error response from an unknown counterparty ({:?})",
+ "Received get_info error response from an unknown counterparty {}",
counterparty_node_id
),
action: ErrorAction::IgnoreAndLog(Level::Debug),
@@ -304,7 +304,7 @@ where
None => {
return Err(LightningError {
err: format!(
- "Received error response for a create order request from an unknown counterparty ({:?})",
+ "Received error response for a create order request from an unknown counterparty {}",
counterparty_node_id
),
action: ErrorAction::IgnoreAndLog(Level::Debug),
diff --git a/lightning-liquidity/src/lsps2/client.rs b/lightning-liquidity/src/lsps2/client.rs
index 71b2a2b..83aa7e3 100644
--- a/lightning-liquidity/src/lsps2/client.rs
+++ b/lightning-liquidity/src/lsps2/client.rs
@@ -227,7 +227,7 @@ where
None => {
return Err(LightningError {
err: format!(
- "Received get_info response from unknown peer: {:?}",
+ "Received get_info response from unknown peer: {}",
counterparty_node_id
),
action: ErrorAction::IgnoreAndLog(Level::Debug),
@@ -275,7 +275,7 @@ where
Err(lightning_error)
},
None => {
- return Err(LightningError { err: format!("Received error response for a get_info request from an unknown counterparty ({:?})",counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError { err: format!("Received error response for a get_info request from an unknown counterparty {}",counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
}
}
@@ -321,7 +321,7 @@ where
None => {
return Err(LightningError {
err: format!(
- "Received buy response from unknown peer: {:?}",
+ "Received buy response from unknown peer: {}",
counterparty_node_id
),
action: ErrorAction::IgnoreAndLog(Level::Debug),
@@ -363,7 +363,13 @@ where
Err(lightning_error)
},
None => {
- return Err(LightningError { err: format!("Received error response for a buy request from an unknown counterparty ({:?})", counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError {
+ err: format!(
+ "Received error response for a buy request from an unknown counterparty {}",
+ counterparty_node_id
+ ),
+ action: ErrorAction::IgnoreAndLog(Level::Debug),
+ });
},
}
}
@@ -400,7 +406,7 @@ where
false,
"Client handler received LSPS2 request message. This should never happen."
);
- Err(LightningError { err: format!("Client handler received LSPS2 request message from node {:?}. This should never happen.", counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)})
+ Err(LightningError { err: format!("Client handler received LSPS2 request message from node {}. This should never happen.", counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)})
},
}
}
diff --git a/lightning-liquidity/src/lsps2/service.rs b/lightning-liquidity/src/lsps2/service.rs
index deadf7a..3747954 100644
--- a/lightning-liquidity/src/lsps2/service.rs
+++ b/lightning-liquidity/src/lsps2/service.rs
@@ -696,7 +696,7 @@ where
}
},
None => Err(APIError::APIMisuseError {
- err: format!("No state for the counterparty exists: {:?}", counterparty_node_id),
+ err: format!("No state for the counterparty exists: {}", counterparty_node_id),
}),
}
}
@@ -752,7 +752,7 @@ where
}
},
None => Err(APIError::APIMisuseError {
- err: format!("No state for the counterparty exists: {:?}", counterparty_node_id),
+ err: format!("No state for the counterparty exists: {}", counterparty_node_id),
}),
}
}
@@ -822,10 +822,7 @@ where
},
None => {
return Err(APIError::APIMisuseError {
- err: format!(
- "No state for the counterparty exists: {:?}",
- counterparty_node_id
- ),
+ err: format!("No state for the counterparty exists: {}", counterparty_node_id),
})
},
};
@@ -1731,7 +1728,7 @@ where
false,
"Service handler received LSPS2 response message. This should never happen."
);
- Err(LightningError { err: format!("Service handler received LSPS2 response message from node {:?}. This should never happen.", counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)})
+ Err(LightningError { err: format!("Service handler received LSPS2 response message from node {}. This should never happen.", counterparty_node_id), action: ErrorAction::IgnoreAndLog(Level::Info)})
},
}
}
diff --git a/lightning-liquidity/src/lsps5/service.rs b/lightning-liquidity/src/lsps5/service.rs
index 2eb5e5f..7ac24ed 100644
--- a/lightning-liquidity/src/lsps5/service.rs
+++ b/lightning-liquidity/src/lsps5/service.rs
@@ -677,7 +677,7 @@ where
"Service handler received LSPS5 response message. This should never happen."
);
let err = format!(
- "Service handler received LSPS5 response message from node {:?}. This should never happen.",
+ "Service handler received LSPS5 response message from node {}. This should never happen.",
counterparty_node_id
);
Err(LightningError { err, action: ErrorAction::IgnoreAndLog(Level::Info) })
diff --git a/lightning-liquidity/src/manager.rs b/lightning-liquidity/src/manager.rs
index 0ea5436..490ca8b 100644
--- a/lightning-liquidity/src/manager.rs
+++ b/lightning-liquidity/src/manager.rs
@@ -680,7 +680,7 @@ where
lsps0_service_handler.handle_message(msg, sender_node_id)?;
},
None => {
- return Err(LightningError { err: format!("Received LSPS0 request message without LSPS0 service handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError { err: format!("Received LSPS0 request message without LSPS0 service handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
}
},
@@ -690,7 +690,7 @@ where
lsps1_client_handler.handle_message(msg, sender_node_id)?;
},
None => {
- return Err(LightningError { err: format!("Received LSPS1 response message without LSPS1 client handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError { err: format!("Received LSPS1 response message without LSPS1 client handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
}
},
@@ -701,11 +701,11 @@ where
lsps1_service_handler.handle_message(_msg, sender_node_id)?;
},
None => {
- return Err(LightningError { err: format!("Received LSPS1 request message without LSPS1 service handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError { err: format!("Received LSPS1 request message without LSPS1 service handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
}
#[cfg(not(lsps1_service))]
- return Err(LightningError { err: format!("Received LSPS1 request message without LSPS1 service handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError { err: format!("Received LSPS1 request message without LSPS1 service handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
LSPSMessage::LSPS2(msg @ LSPS2Message::Response(..)) => {
match &self.lsps2_client_handler {
@@ -713,7 +713,7 @@ where
lsps2_client_handler.handle_message(msg, sender_node_id)?;
},
None => {
- return Err(LightningError { err: format!("Received LSPS2 response message without LSPS2 client handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError { err: format!("Received LSPS2 response message without LSPS2 client handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
}
},
@@ -723,7 +723,7 @@ where
lsps2_service_handler.handle_message(msg, sender_node_id)?;
},
None => {
- return Err(LightningError { err: format!("Received LSPS2 request message without LSPS2 service handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError { err: format!("Received LSPS2 request message without LSPS2 service handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
}
},
@@ -733,7 +733,7 @@ where
lsps5_client_handler.handle_message(msg, sender_node_id)?;
},
None => {
- return Err(LightningError { err: format!("Received LSPS5 response message without LSPS5 client handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError { err: format!("Received LSPS5 response message without LSPS5 client handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
}
},
@@ -766,7 +766,7 @@ where
lsps5_service_handler.handle_message(msg, sender_node_id)?;
},
None => {
- return Err(LightningError { err: format!("Received LSPS5 request message without LSPS5 service handler configured. From node = {:?}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
+ return Err(LightningError { err: format!("Received LSPS5 request message without LSPS5 service handler configured. From node {}", sender_node_id), action: ErrorAction::IgnoreAndLog(Level::Debug)});
},
}
},
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.