multi: don't leak underlying pointer to LightningChannel.ChannelPoint()

This commit is contained in:
Keagan McClelland committed 2024-03-08 15:27:19 -08:00
1 parent e9b3808c29
commit fd1cd315ce
11 files changed
+53 -42

No files matched your search

+3 -3
View File
@@ -3209,10 +3209,10 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
// First, we'll clear all indexes related to the channel in question.
chanPoint := chanCloser.Channel().ChannelPoint()
p.WipeChannel(chanPoint)
p.WipeChannel(&chanPoint)
// Also clear the activeChanCloses map of this channel.
cid := lnwire.NewChanIDFromOutPoint(chanPoint)
cid := lnwire.NewChanIDFromOutPoint(&chanPoint)
delete(p.activeChanCloses, cid)
// Next, we'll launch a goroutine which will request to be notified by
@@ -3247,7 +3247,7 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
}
go WaitForChanToClose(chanCloser.NegotiationHeight(), notifier, errChan,
chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, func() {
&chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, func() {
// Respond to the local subsystem which requested the
// channel closure.
if closeReq != nil {
+14 -9
View File
@@ -53,7 +53,8 @@ func TestPeerChannelClosureShutdownResponseLinkRemoved(t *testing.T) {
)
require.NoError(t, err, "unable to create test channels")
chanID := lnwire.NewChanIDFromOutPoint(bobChan.ChannelPoint())
chanPoint := bobChan.ChannelPoint()
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
dummyDeliveryScript := genScript(t, p2wshAddress)
@@ -100,7 +101,8 @@ func TestPeerChannelClosureAcceptFeeResponder(t *testing.T) {
)
require.NoError(t, err, "unable to create test channels")
chanID := lnwire.NewChanIDFromOutPoint(bobChan.ChannelPoint())
chanPoint := bobChan.ChannelPoint()
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
mockLink := newMockUpdateHandler(chanID)
mockSwitch.links = append(mockSwitch.links, mockLink)
@@ -204,7 +206,8 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
)
require.NoError(t, err, "unable to create test channels")
chanID := lnwire.NewChanIDFromOutPoint(bobChan.ChannelPoint())
chanPoint := bobChan.ChannelPoint()
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
mockLink := newMockUpdateHandler(chanID)
mockSwitch.links = append(mockSwitch.links, mockLink)
@@ -215,7 +218,7 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
errChan := make(chan error, 1)
closeCommand := &htlcswitch.ChanClose{
CloseType: contractcourt.CloseRegular,
ChanPoint: bobChan.ChannelPoint(),
ChanPoint: &chanPoint,
Updates: updateChan,
TargetFeePerKw: 12500,
Err: errChan,
@@ -327,7 +330,8 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
)
require.NoError(t, err, "unable to create test channels")
chanID := lnwire.NewChanIDFromOutPoint(bobChan.ChannelPoint())
chanPoint := bobChan.ChannelPoint()
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
mockLink := newMockUpdateHandler(chanID)
mockSwitch.links = append(mockSwitch.links, mockLink)
@@ -513,7 +517,8 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
)
require.NoError(t, err, "unable to create test channels")
chanID := lnwire.NewChanIDFromOutPoint(bobChan.ChannelPoint())
chanPoint := bobChan.ChannelPoint()
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
mockLink := newMockUpdateHandler(chanID)
mockSwitch.links = append(mockSwitch.links, mockLink)
@@ -522,7 +527,7 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
errChan := make(chan error, 1)
closeCommand := &htlcswitch.ChanClose{
CloseType: contractcourt.CloseRegular,
ChanPoint: bobChan.ChannelPoint(),
ChanPoint: &chanPoint,
Updates: updateChan,
TargetFeePerKw: 12500,
Err: errChan,
@@ -844,7 +849,7 @@ func TestCustomShutdownScript(t *testing.T) {
}
chanPoint := bobChan.ChannelPoint()
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
mockLink := newMockUpdateHandler(chanID)
mockSwitch.links = append(mockSwitch.links, mockLink)
@@ -854,7 +859,7 @@ func TestCustomShutdownScript(t *testing.T) {
errChan := make(chan error, 1)
closeCommand := htlcswitch.ChanClose{
CloseType: contractcourt.CloseRegular,
ChanPoint: chanPoint,
ChanPoint: &chanPoint,
Updates: updateChan,
TargetFeePerKw: 12500,
DeliveryScript: test.userCloseScript,
+2 -1
View File
@@ -412,7 +412,8 @@ func createTestPeer(t *testing.T, notifier chainntnfs.ChainNotifier,
alicePeer := NewBrontide(*cfg)
alicePeer.remoteFeatures = lnwire.NewFeatureVector(nil, lnwire.Features)
chanID := lnwire.NewChanIDFromOutPoint(channelAlice.ChannelPoint())
chanPoint := channelAlice.ChannelPoint()
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
alicePeer.activeChannels.Store(chanID, channelAlice)
alicePeer.wg.Add(1)