htlcswitch: prevent ChannelLink from leaking ChannelPoint pointer

This commit is contained in:
Keagan McClelland 2024-01-29 16:55:20 -05:00
parent db39a905cb
commit 16be46c1e5
3 changed files with 11 additions and 9 deletions

View File

@ -221,7 +221,7 @@ type ChannelLink interface {
IsUnadvertised() bool
// ChannelPoint returns the channel outpoint for the channel link.
ChannelPoint() *wire.OutPoint
ChannelPoint() wire.OutPoint
// ShortChanID returns the short channel ID for the channel link. The
// short channel ID encodes the exact location in the main chain that

View File

@ -1090,8 +1090,8 @@ func (l *channelLink) htlcManager() {
// ActiveLinkEvent. We'll also defer an inactive link notification for
// when the link exits to ensure that every active notification is
// matched by an inactive one.
l.cfg.NotifyActiveLink(*l.ChannelPoint())
defer l.cfg.NotifyInactiveLinkEvent(*l.ChannelPoint())
l.cfg.NotifyActiveLink(l.ChannelPoint())
defer l.cfg.NotifyInactiveLinkEvent(l.ChannelPoint())
// TODO(roasbeef): need to call wipe chan whenever D/C?
@ -1215,8 +1215,8 @@ func (l *channelLink) htlcManager() {
// we can go ahead and send the active channel notification. We'll also
// defer the inactive notification for when the link exits to ensure
// that every active notification is matched by an inactive one.
l.cfg.NotifyActiveChannel(*l.ChannelPoint())
defer l.cfg.NotifyInactiveChannel(*l.ChannelPoint())
l.cfg.NotifyActiveChannel(l.ChannelPoint())
defer l.cfg.NotifyInactiveChannel(l.ChannelPoint())
// With the channel states synced, we now reset the mailbox to ensure
// we start processing all unacked packets in order. This is done here
@ -2558,9 +2558,8 @@ func (l *channelLink) PeerPubKey() [33]byte {
// ChannelPoint returns the channel outpoint for the channel link.
// NOTE: Part of the ChannelLink interface.
func (l *channelLink) ChannelPoint() *wire.OutPoint {
chanPoint := l.channel.ChannelPoint()
return &chanPoint
func (l *channelLink) ChannelPoint() wire.OutPoint {
return l.channel.ChannelPoint()
}
// ShortChanID returns the short channel ID for the channel link. The short

View File

@ -907,7 +907,10 @@ func (f *mockChannelLink) PeerPubKey() [33]byte {
return f.peer.PubKey()
}
func (f *mockChannelLink) ChannelPoint() *wire.OutPoint { return &wire.OutPoint{} }
func (f *mockChannelLink) ChannelPoint() wire.OutPoint {
return wire.OutPoint{}
}
func (f *mockChannelLink) Stop() {}
func (f *mockChannelLink) EligibleToForward() bool { return f.eligible }
func (f *mockChannelLink) MayAddOutgoingHtlc(lnwire.MilliSatoshi) error { return nil }