diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 71fe56e3..0aa81435 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1969,8 +1969,8 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64, // With the commitment outputs located, we'll now generate all the // retribution structs for each of the HTLC transactions active on the // remote commitment transaction. - htlcRetributions := make([]HtlcRetribution, len(revokedSnapshot.Htlcs)) - for i, htlc := range revokedSnapshot.Htlcs { + htlcRetributions := make([]HtlcRetribution, 0, len(revokedSnapshot.Htlcs)) + for _, htlc := range revokedSnapshot.Htlcs { var ( htlcScript []byte err error @@ -2023,7 +2023,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64, } } - htlcRetributions[i] = HtlcRetribution{ + htlcRetributions = append(htlcRetributions, HtlcRetribution{ SignDesc: SignDescriptor{ KeyDesc: chanState.LocalChanCfg.RevocationBasePoint, DoubleTweak: commitmentSecret, @@ -2039,7 +2039,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64, }, SecondLevelWitnessScript: secondLevelWitnessScript, IsIncoming: htlc.Incoming, - } + }) } // Finally, with all the necessary data constructed, we can create the