@@ -349,23 +349,13 @@ type commitment struct {
349349
350350// locateOutputIndex is a small helper function to locate the output index of a
351351// particular HTLC within the current commitment transaction. The duplicate map
352- // massed in is to be retained for each output within the commitment
352+ // passed in is to be retained for each output within the commitment
353353// transition. This ensures that we don't assign multiple HTLCs to the same
354354// index within the commitment transaction.
355355func locateOutputIndex (p * PaymentDescriptor , tx * wire.MsgTx ,
356356 whoseCommit lntypes.ChannelParty , dups map [PaymentHash ][]int32 ,
357357 cltvs []uint32 ) (int32 , error ) {
358358
359- // Checks to see if element (e) exists in slice (s).
360- contains := func (s []int32 , e int32 ) bool {
361- for _ , a := range s {
362- if a == e {
363- return true
364- }
365- }
366- return false
367- }
368-
369359 // If this is their commitment transaction, we'll be trying to locate
370360 // their pkScripts, otherwise we'll be looking for ours. This is
371361 // required as the commitment states are asymmetric in order to ascribe
@@ -385,7 +375,7 @@ func locateOutputIndex(p *PaymentDescriptor, tx *wire.MsgTx,
385375 // If this payment hash and index has already been
386376 // found, then we'll continue in order to avoid any
387377 // duplicate indexes.
388- if contains ( dups [p .RHash ], int32 ( i ) ) {
378+ if fn . Elem ( int32 ( i ), dups [p .RHash ]) {
389379 continue
390380 }
391381
@@ -576,7 +566,7 @@ func (c *commitment) toDiskCommit(
576566// restore commitment state written to disk back into memory once we need to
577567// restart a channel session.
578568func (lc * LightningChannel ) diskHtlcToPayDesc (feeRate chainfee.SatPerKWeight ,
579- commitHeight uint64 , htlc * channeldb.HTLC , localCommitKeys ,
569+ htlc * channeldb.HTLC , localCommitKeys * CommitmentKeyRing ,
580570 remoteCommitKeys * CommitmentKeyRing , whoseCommit lntypes.ChannelParty ,
581571) (PaymentDescriptor , error ) {
582572
@@ -664,8 +654,8 @@ func (lc *LightningChannel) diskHtlcToPayDesc(feeRate chainfee.SatPerKWeight,
664654// to a set of incoming and outgoing payment descriptors. Once reconstructed,
665655// these payment descriptors can be re-inserted into the in-memory updateLog
666656// for each side.
667- func (lc * LightningChannel ) extractPayDescs (commitHeight uint64 ,
668- feeRate chainfee. SatPerKWeight , htlcs []channeldb.HTLC , localCommitKeys ,
657+ func (lc * LightningChannel ) extractPayDescs (feeRate chainfee. SatPerKWeight ,
658+ htlcs []channeldb.HTLC , localCommitKeys * CommitmentKeyRing ,
669659 remoteCommitKeys * CommitmentKeyRing , whoseCommit lntypes.ChannelParty ,
670660) ([]PaymentDescriptor , []PaymentDescriptor , error ) {
671661
@@ -685,7 +675,7 @@ func (lc *LightningChannel) extractPayDescs(commitHeight uint64,
685675 htlc := htlc
686676
687677 payDesc , err := lc .diskHtlcToPayDesc (
688- feeRate , commitHeight , & htlc ,
678+ feeRate , & htlc ,
689679 localCommitKeys , remoteCommitKeys ,
690680 whoseCommit ,
691681 )
@@ -738,7 +728,6 @@ func (lc *LightningChannel) diskCommitToMemCommit(
738728 // HTLC"s into PaymentDescriptor's so we can re-insert them into our
739729 // update log.
740730 incomingHtlcs , outgoingHtlcs , err := lc .extractPayDescs (
741- diskCommit .CommitHeight ,
742731 chainfee .SatPerKWeight (diskCommit .FeePerKw ),
743732 diskCommit .Htlcs , localCommitKeys , remoteCommitKeys ,
744733 whoseCommit ,
0 commit comments