From ce27b3450062bd32fcf5c99248130f1d3d98d213 Mon Sep 17 00:00:00 2001 From: ziggie Date: Mon, 16 Dec 2024 15:07:07 +0100 Subject: [PATCH] lnwire: add string method to channel_ready type --- lnwire/channel_ready.go | 16 ++++++++++++++++ peer/brontide.go | 3 +-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lnwire/channel_ready.go b/lnwire/channel_ready.go index 912a068bde..813f1c1ed0 100644 --- a/lnwire/channel_ready.go +++ b/lnwire/channel_ready.go @@ -2,6 +2,7 @@ package lnwire import ( "bytes" + "fmt" "io" "github.com/btcsuite/btcd/btcec/v2" @@ -170,3 +171,18 @@ func (c *ChannelReady) Encode(w *bytes.Buffer, _ uint32) error { func (c *ChannelReady) MsgType() MessageType { return MsgChannelReady } + +// String returns a human-readable description of the ChannelReady msg. +func (c *ChannelReady) String() string { + // Handle the case where the AliasScid is nil. + aliasStr := "nil" + if c.AliasScid != nil { + aliasStr = fmt.Sprintf("%v(uint=%d)", + c.AliasScid, c.AliasScid.ToUint64()) + } + + return fmt.Sprintf("chan_id=%v, next_point=%x, aliasSCID=%s", + c.ChanID, c.NextPerCommitmentPoint.SerializeCompressed(), + aliasStr, + ) +} diff --git a/peer/brontide.go b/peer/brontide.go index f0399b4e8a..c7fc4b6f46 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -2268,8 +2268,7 @@ func messageSummary(msg lnwire.Message) string { return fmt.Sprintf("chan_id=%v", msg.ChanID) case *lnwire.ChannelReady: - return fmt.Sprintf("chan_id=%v, next_point=%x", - msg.ChanID, msg.NextPerCommitmentPoint.SerializeCompressed()) + return msg.String() case *lnwire.Shutdown: return fmt.Sprintf("chan_id=%v, script=%x", msg.ChannelID,