Skip to content

Commit 16be46c

Browse files
committed
htlcswitch: prevent ChannelLink from leaking ChannelPoint pointer
1 parent db39a90 commit 16be46c

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

htlcswitch/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ type ChannelLink interface {
221221
IsUnadvertised() bool
222222

223223
// ChannelPoint returns the channel outpoint for the channel link.
224-
ChannelPoint() *wire.OutPoint
224+
ChannelPoint() wire.OutPoint
225225

226226
// ShortChanID returns the short channel ID for the channel link. The
227227
// short channel ID encodes the exact location in the main chain that

htlcswitch/link.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,8 @@ func (l *channelLink) htlcManager() {
10901090
// ActiveLinkEvent. We'll also defer an inactive link notification for
10911091
// when the link exits to ensure that every active notification is
10921092
// matched by an inactive one.
1093-
l.cfg.NotifyActiveLink(*l.ChannelPoint())
1094-
defer l.cfg.NotifyInactiveLinkEvent(*l.ChannelPoint())
1093+
l.cfg.NotifyActiveLink(l.ChannelPoint())
1094+
defer l.cfg.NotifyInactiveLinkEvent(l.ChannelPoint())
10951095

10961096
// TODO(roasbeef): need to call wipe chan whenever D/C?
10971097

@@ -1215,8 +1215,8 @@ func (l *channelLink) htlcManager() {
12151215
// we can go ahead and send the active channel notification. We'll also
12161216
// defer the inactive notification for when the link exits to ensure
12171217
// that every active notification is matched by an inactive one.
1218-
l.cfg.NotifyActiveChannel(*l.ChannelPoint())
1219-
defer l.cfg.NotifyInactiveChannel(*l.ChannelPoint())
1218+
l.cfg.NotifyActiveChannel(l.ChannelPoint())
1219+
defer l.cfg.NotifyInactiveChannel(l.ChannelPoint())
12201220

12211221
// With the channel states synced, we now reset the mailbox to ensure
12221222
// we start processing all unacked packets in order. This is done here
@@ -2558,9 +2558,8 @@ func (l *channelLink) PeerPubKey() [33]byte {
25582558

25592559
// ChannelPoint returns the channel outpoint for the channel link.
25602560
// NOTE: Part of the ChannelLink interface.
2561-
func (l *channelLink) ChannelPoint() *wire.OutPoint {
2562-
chanPoint := l.channel.ChannelPoint()
2563-
return &chanPoint
2561+
func (l *channelLink) ChannelPoint() wire.OutPoint {
2562+
return l.channel.ChannelPoint()
25642563
}
25652564

25662565
// ShortChanID returns the short channel ID for the channel link. The short

htlcswitch/mock.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,10 @@ func (f *mockChannelLink) PeerPubKey() [33]byte {
907907
return f.peer.PubKey()
908908
}
909909

910-
func (f *mockChannelLink) ChannelPoint() *wire.OutPoint { return &wire.OutPoint{} }
910+
func (f *mockChannelLink) ChannelPoint() wire.OutPoint {
911+
return wire.OutPoint{}
912+
}
913+
911914
func (f *mockChannelLink) Stop() {}
912915
func (f *mockChannelLink) EligibleToForward() bool { return f.eligible }
913916
func (f *mockChannelLink) MayAddOutgoingHtlc(lnwire.MilliSatoshi) error { return nil }

0 commit comments

Comments
 (0)