@@ -575,9 +575,8 @@ func (c *commitment) toDiskCommit(
575575// restore commitment state written to disk back into memory once we need to
576576// restart a channel session.
577577func (lc * LightningChannel ) diskHtlcToPayDesc (feeRate chainfee.SatPerKWeight ,
578- htlc * channeldb.HTLC , localCommitKeys * CommitmentKeyRing ,
579- remoteCommitKeys * CommitmentKeyRing , whoseCommit lntypes.ChannelParty ,
580- ) (PaymentDescriptor , error ) {
578+ htlc * channeldb.HTLC , commitKeys lntypes.Dual [* CommitmentKeyRing ],
579+ whoseCommit lntypes.ChannelParty ) (PaymentDescriptor , error ) {
581580
582581 // The proper pkScripts for this PaymentDescriptor must be
583582 // generated so we can easily locate them within the commitment
@@ -598,6 +597,7 @@ func (lc *LightningChannel) diskHtlcToPayDesc(feeRate chainfee.SatPerKWeight,
598597 chanType , htlc .Incoming , lntypes .Local , feeRate ,
599598 htlc .Amt .ToSatoshis (), lc .channelState .LocalChanCfg .DustLimit ,
600599 )
600+ localCommitKeys := commitKeys .GetForParty (lntypes .Local )
601601 if ! isDustLocal && localCommitKeys != nil {
602602 scriptInfo , err := genHtlcScript (
603603 chanType , htlc .Incoming , lntypes .Local ,
@@ -613,6 +613,7 @@ func (lc *LightningChannel) diskHtlcToPayDesc(feeRate chainfee.SatPerKWeight,
613613 chanType , htlc .Incoming , lntypes .Remote , feeRate ,
614614 htlc .Amt .ToSatoshis (), lc .channelState .RemoteChanCfg .DustLimit ,
615615 )
616+ remoteCommitKeys := commitKeys .GetForParty (lntypes .Remote )
616617 if ! isDustRemote && remoteCommitKeys != nil {
617618 scriptInfo , err := genHtlcScript (
618619 chanType , htlc .Incoming , lntypes .Remote ,
@@ -665,9 +666,9 @@ func (lc *LightningChannel) diskHtlcToPayDesc(feeRate chainfee.SatPerKWeight,
665666// these payment descriptors can be re-inserted into the in-memory updateLog
666667// for each side.
667668func (lc * LightningChannel ) extractPayDescs (feeRate chainfee.SatPerKWeight ,
668- htlcs []channeldb.HTLC , localCommitKeys * CommitmentKeyRing ,
669- remoteCommitKeys * CommitmentKeyRing , whoseCommit lntypes.ChannelParty ,
670- ) ([] PaymentDescriptor , []PaymentDescriptor , error ) {
669+ htlcs []channeldb.HTLC , commitKeys lntypes. Dual [ * CommitmentKeyRing ] ,
670+ whoseCommit lntypes.ChannelParty ) ([] PaymentDescriptor ,
671+ []PaymentDescriptor , error ) {
671672
672673 var (
673674 incomingHtlcs []PaymentDescriptor
@@ -685,9 +686,7 @@ func (lc *LightningChannel) extractPayDescs(feeRate chainfee.SatPerKWeight,
685686 htlc := htlc
686687
687688 payDesc , err := lc .diskHtlcToPayDesc (
688- feeRate , & htlc ,
689- localCommitKeys , remoteCommitKeys ,
690- whoseCommit ,
689+ feeRate , & htlc , commitKeys , whoseCommit ,
691690 )
692691 if err != nil {
693692 return incomingHtlcs , outgoingHtlcs , err
@@ -716,31 +715,30 @@ func (lc *LightningChannel) diskCommitToMemCommit(
716715 // (we extended but weren't able to complete the commitment dance
717716 // before shutdown), then the localCommitPoint won't be set as we
718717 // haven't yet received a responding commitment from the remote party.
719- var localCommitKeys , remoteCommitKeys * CommitmentKeyRing
718+ var commitKeys lntypes. Dual [ * CommitmentKeyRing ]
720719 if localCommitPoint != nil {
721- localCommitKeys = DeriveCommitmentKeys (
720+ commitKeys . SetForParty ( lntypes . Local , DeriveCommitmentKeys (
722721 localCommitPoint , lntypes .Local ,
723722 lc .channelState .ChanType ,
724723 & lc .channelState .LocalChanCfg ,
725724 & lc .channelState .RemoteChanCfg ,
726- )
725+ ))
727726 }
728727 if remoteCommitPoint != nil {
729- remoteCommitKeys = DeriveCommitmentKeys (
728+ commitKeys . SetForParty ( lntypes . Remote , DeriveCommitmentKeys (
730729 remoteCommitPoint , lntypes .Remote ,
731730 lc .channelState .ChanType ,
732731 & lc .channelState .LocalChanCfg ,
733732 & lc .channelState .RemoteChanCfg ,
734- )
733+ ))
735734 }
736735
737736 // With the key rings re-created, we'll now convert all the on-disk
738737 // HTLC"s into PaymentDescriptor's so we can re-insert them into our
739738 // update log.
740739 incomingHtlcs , outgoingHtlcs , err := lc .extractPayDescs (
741740 chainfee .SatPerKWeight (diskCommit .FeePerKw ),
742- diskCommit .Htlcs , localCommitKeys , remoteCommitKeys ,
743- whoseCommit ,
741+ diskCommit .Htlcs , commitKeys , whoseCommit ,
744742 )
745743 if err != nil {
746744 return nil , err
0 commit comments