lnwire: implement SerializedSize for onion messages
What changed, and why it matters
This commit adds a missing helper method that reports how many bytes an onion message occupies when serialized. It is a small interface-compliance change with no direct security fix visible in the diff. Any security relevance would come from how downstream code uses this size information, but that behavior is not shown here.
Treat as a normal code-quality/interface-completion change. Review callers of SerializedSize to confirm the size value is used safely (e.g., not trusted for unchecked buffer allocation), but no immediate security action is indicated by this commit alone.
Security signals we found
New interface implementation added to onion-routing message type
No input validation, memory limits, or parsing hardening present in diff
No vendor security framing or CVE references in commit metadata
Evidence from the diff
The patch implements SerializedSize() for lnwire.OnionMessage by delegating to MessageSerializedSize(o). This makes OnionMessage satisfy the SizeableMessage interface. The change is purely additive (+9 lines) and contains no logic for bounds checking, allocation limits, or parsing changes. Without additional context, it reads as a routine API completeness commit rather than a vulnerability remediation.
Changed components
lnwire/onion_message.goOnionMessage typeSizeableMessage interfaceInspect captured patch +9 / −0
diff --git a/lnwire/onion_message.go b/lnwire/onion_message.go
index cabbc21..5d56808 100644
--- a/lnwire/onion_message.go
+++ b/lnwire/onion_message.go
@@ -36,6 +36,8 @@ func NewOnionMessage(pathKey *btcec.PublicKey,
// A compile-time check to ensure OnionMessage implements the Message interface.
var _ Message = (*OnionMessage)(nil)
+var _ SizeableMessage = (*OnionMessage)(nil)
+
// Decode reads the bytes stream and converts it to the object.
func (o *OnionMessage) Decode(r io.Reader, _ uint32) error {
if err := ReadElement(r, &o.PathKey); err != nil {
@@ -79,3 +81,10 @@ func (o *OnionMessage) Encode(w *bytes.Buffer, _ uint32) error {
func (o *OnionMessage) MsgType() MessageType {
return MsgOnionMessage
}
+
+// SerializedSize returns the serialized size of the message in bytes.
+//
+// This is part of the lnwire.SizeableMessage interface.
+func (o *OnionMessage) SerializedSize() (uint32, error) {
+ return MessageSerializedSize(o)
+}
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.