From e9b3808c29804468556e6a4326a479fb71c22f7e Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Mon, 29 Jan 2024 15:46:38 -0500 Subject: [PATCH] lnwallet+contractcourt: remove redundant ChanPoint field --- contractcourt/breach_arbitrator_test.go | 20 ++++++++++---------- lnwallet/channel.go | 4 ---- lnwallet/transactions_test.go | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/contractcourt/breach_arbitrator_test.go b/contractcourt/breach_arbitrator_test.go index 29f33881a..4d6f3f35e 100644 --- a/contractcourt/breach_arbitrator_test.go +++ b/contractcourt/breach_arbitrator_test.go @@ -1010,7 +1010,7 @@ func initBreachedState(t *testing.T) (*BreachArbitrator, func TestBreachHandoffSuccess(t *testing.T) { brar, alice, _, bobClose, contractBreaches := initBreachedState(t) - chanPoint := alice.ChanPoint + chanPoint := alice.ChannelPoint() // Signal a spend of the funding transaction and wait for the close // observer to exit. @@ -1096,7 +1096,7 @@ func TestBreachHandoffFail(t *testing.T) { // Signal the notifier to dispatch spend notifications of the funding // transaction using the transaction from bob's closing summary. - chanPoint := alice.ChanPoint + chanPoint := alice.ChannelPoint() processACK := make(chan error) breach := &ContractBreachEvent{ ChanPoint: *chanPoint, @@ -1560,7 +1560,7 @@ func testBreachSpends(t *testing.T, test breachTest) { var ( height = bobClose.ChanSnapshot.CommitHeight forceCloseTx = bobClose.CloseTx - chanPoint = alice.ChanPoint + chanPoint = alice.ChannelPoint() publTx = make(chan *wire.MsgTx) publErr error publMtx sync.Mutex @@ -1764,7 +1764,7 @@ func testBreachSpends(t *testing.T, test breachTest) { } // Assert that the channel is fully resolved. - assertBrarCleanup(t, brar, alice.ChanPoint, alice.State().Db) + assertBrarCleanup(t, brar, alice.ChannelPoint(), alice.State().Db) } // TestBreachDelayedJusticeConfirmation tests that the breach arbiter will @@ -1777,7 +1777,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) { height = bobClose.ChanSnapshot.CommitHeight blockHeight = int32(10) forceCloseTx = bobClose.CloseTx - chanPoint = alice.ChanPoint + chanPoint = alice.ChannelPoint() publTx = make(chan *wire.MsgTx) ) @@ -1965,7 +1965,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) { } // Assert that the channel is fully resolved. - assertBrarCleanup(t, brar, alice.ChanPoint, alice.State().Db) + assertBrarCleanup(t, brar, alice.ChannelPoint(), alice.State().Db) } // findInputIndex returns the index of the input that spends from the given @@ -2081,12 +2081,12 @@ func assertPendingClosed(t *testing.T, c *lnwallet.LightningChannel) { require.NoError(t, err, "unable to load pending closed channels") for _, chanSummary := range closedChans { - if chanSummary.ChanPoint == *c.ChanPoint { + if chanSummary.ChanPoint == *c.ChannelPoint() { return } } - t.Fatalf("channel %v was not marked pending closed", c.ChanPoint) + t.Fatalf("channel %v was not marked pending closed", c.ChannelPoint()) } // assertNotPendingClosed checks that the channel has not been marked pending @@ -2098,9 +2098,9 @@ func assertNotPendingClosed(t *testing.T, c *lnwallet.LightningChannel) { require.NoError(t, err, "unable to load pending closed channels") for _, chanSummary := range closedChans { - if chanSummary.ChanPoint == *c.ChanPoint { + if chanSummary.ChanPoint == *c.ChannelPoint() { t.Fatalf("channel %v was marked pending closed", - c.ChanPoint) + c.ChannelPoint()) } } } diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 5e6af76c8..839646c44 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1260,9 +1260,6 @@ type LightningChannel struct { isClosed bool - // ChanPoint is the funding outpoint of this channel. - ChanPoint *wire.OutPoint - // sigPool is a pool of workers that are capable of signing and // validating signatures in parallel. This is utilized as an // optimization to void serially signing or validating the HTLC @@ -1412,7 +1409,6 @@ func NewLightningChannel(signer input.Signer, commitBuilder: NewCommitmentBuilder(state), localUpdateLog: localUpdateLog, remoteUpdateLog: remoteUpdateLog, - ChanPoint: &state.FundingOutpoint, Capacity: state.Capacity, taprootNonceProducer: taprootNonceProducer, log: build.NewPrefixLog(logPrefix, walletLog), diff --git a/lnwallet/transactions_test.go b/lnwallet/transactions_test.go index 550586a4c..ab0ef7328 100644 --- a/lnwallet/transactions_test.go +++ b/lnwallet/transactions_test.go @@ -269,7 +269,7 @@ func addTestHtlcs(t *testing.T, remote, local *LightningChannel, hash160map[hash160] = preimage // Add htlc to the channel. - chanID := lnwire.NewChanIDFromOutPoint(remote.ChanPoint) + chanID := lnwire.NewChanIDFromOutPoint(remote.ChannelPoint()) msg := &lnwire.UpdateAddHTLC{ Amount: htlc.amount,