Merge pull request #8425 from ProofOfKeags/refactor/lnwallet/chan-point-leaks
[EZ Review]: avoid leaking pointers to authoritative ChannelPoint
This commit is contained in:
31 files changed
+160
-149
No files matched your search
@@ -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
|
||||
|
||||
+6
-6
@@ -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
|
||||
@@ -1371,7 +1371,7 @@ func (l *channelLink) htlcManager() {
|
||||
// TODO(roasbeef): remove all together
|
||||
go func() {
|
||||
chanPoint := l.channel.ChannelPoint()
|
||||
l.cfg.Peer.WipeChannel(chanPoint)
|
||||
l.cfg.Peer.WipeChannel(&chanPoint)
|
||||
}()
|
||||
|
||||
return
|
||||
@@ -2558,7 +2558,7 @@ 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 {
|
||||
func (l *channelLink) ChannelPoint() wire.OutPoint {
|
||||
return l.channel.ChannelPoint()
|
||||
}
|
||||
|
||||
|
||||
@@ -1497,7 +1497,7 @@ func TestChannelLinkMultiHopUnknownNextHop(t *testing.T) {
|
||||
// back the payment to Alice since he is unaware of Carol when the
|
||||
// payment comes across.
|
||||
bobChanID := lnwire.NewChanIDFromOutPoint(
|
||||
&channels.bobToCarol.State().FundingOutpoint,
|
||||
channels.bobToCarol.ChannelPoint(),
|
||||
)
|
||||
n.bobServer.htlcSwitch.RemoveLink(bobChanID)
|
||||
|
||||
@@ -3762,7 +3762,8 @@ func TestChannelRetransmission(t *testing.T) {
|
||||
t.Fatalf("unable to create channel: %v", err)
|
||||
}
|
||||
|
||||
chanID := lnwire.NewChanIDFromOutPoint(channels.aliceToBob.ChannelPoint())
|
||||
chanPoint := channels.aliceToBob.ChannelPoint()
|
||||
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||
serverErr := make(chan error, 4)
|
||||
|
||||
aliceInterceptor := createInterceptorFunc("[alice] <-- [bob]",
|
||||
|
||||
+4
-1
@@ -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 }
|
||||
|
||||
@@ -621,7 +621,7 @@ func (s *Switch) UpdateForwardingPolicies(
|
||||
|
||||
// Update each link in chanPolicies.
|
||||
for targetLink, policy := range chanPolicies {
|
||||
cid := lnwire.NewChanIDFromOutPoint(&targetLink)
|
||||
cid := lnwire.NewChanIDFromOutPoint(targetLink)
|
||||
|
||||
link, ok := s.linkIndex[cid]
|
||||
if !ok {
|
||||
@@ -1797,7 +1797,7 @@ out:
|
||||
// relevant link (if it exists) so the channel can be
|
||||
// cooperatively closed (if possible).
|
||||
case req := <-s.chanCloseRequests:
|
||||
chanID := lnwire.NewChanIDFromOutPoint(req.ChanPoint)
|
||||
chanID := lnwire.NewChanIDFromOutPoint(*req.ChanPoint)
|
||||
|
||||
s.indexMtx.RLock()
|
||||
link, ok := s.linkIndex[chanID]
|
||||
|
||||
@@ -73,7 +73,7 @@ func genID() (lnwire.ChannelID, lnwire.ShortChannelID) {
|
||||
hash1, _ := chainhash.NewHash(bytes.Repeat(scratch[:], 4))
|
||||
|
||||
chanPoint1 := wire.NewOutPoint(hash1, uint32(id))
|
||||
chanID1 := lnwire.NewChanIDFromOutPoint(chanPoint1)
|
||||
chanID1 := lnwire.NewChanIDFromOutPoint(*chanPoint1)
|
||||
aliceChanID := lnwire.NewShortChanIDFromInt(id)
|
||||
|
||||
return chanID1, aliceChanID
|
||||
|
||||
Reference in new issue
Block a user