Skip to content

Commit

Permalink
lnwire: add string method to channel_ready type
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggie1984 committed Dec 20, 2024
1 parent 0c76e29 commit ce27b34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 16 additions & 0 deletions lnwire/channel_ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lnwire

import (
"bytes"
"fmt"
"io"

"github.com/btcsuite/btcd/btcec/v2"
Expand Down Expand Up @@ -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,
)
}
3 changes: 1 addition & 2 deletions peer/brontide.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ce27b34

Please sign in to comment.