@@ -2108,7 +2108,12 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
21082108 return l .LocalAuxLeaf
21092109 },
21102110 )(auxResult .AuxLeaves )
2111- theirDelay := uint32 (chanState .ChanCfgs .Remote .CsvDelay )
2111+ theirDelay := uint32 (
2112+ chanState .CommitChainEpochHistory .NormalizedParamsAt (
2113+ lntypes .Remote , stateNum ,
2114+ ).CsvDelay ,
2115+ )
2116+
21122117 theirScript , err := CommitScriptToSelf (
21132118 chanState .ChanType , isRemoteInitiator , keyRing .ToLocalKey ,
21142119 keyRing .RevocationKey , theirDelay , leaseExpiry , localAuxLeaf ,
@@ -2128,7 +2133,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
21282133 // we need.
21292134 if revokedLog != nil {
21302135 br , ourAmt , theirAmt , err = createBreachRetribution (
2131- revokedLog , spendTx , chanState , keyRing ,
2136+ revokedLog , spendTx , chanState , stateNum , keyRing ,
21322137 commitmentSecret , leaseExpiry , auxResult .AuxLeaves ,
21332138 )
21342139 if err != nil {
@@ -2143,8 +2148,8 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
21432148 // data can still function. This branch can be deleted once we
21442149 // are confident that no legacy format is in use.
21452150 br , ourAmt , theirAmt , err = createBreachRetributionLegacy (
2146- revokedLogLegacy , chanState , keyRing , commitmentSecret ,
2147- ourScript , theirScript , leaseExpiry ,
2151+ revokedLogLegacy , chanState , stateNum , keyRing ,
2152+ commitmentSecret , ourScript , theirScript , leaseExpiry ,
21482153 )
21492154 if err != nil {
21502155 return nil , err
@@ -2325,15 +2330,19 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
23252330
23262331// createHtlcRetribution is a helper function to construct an HtlcRetribution
23272332// based on the passed params.
2328- func createHtlcRetribution (chanState * channeldb.OpenChannel ,
2333+ func createHtlcRetribution (chanState * channeldb.OpenChannel , stateNum uint64 ,
23292334 keyRing * CommitmentKeyRing , commitHash chainhash.Hash ,
23302335 commitmentSecret * btcec.PrivateKey , leaseExpiry uint32 ,
23312336 htlc * channeldb.HTLCEntry ,
23322337 auxLeaves fn.Option [CommitAuxLeaves ]) (HtlcRetribution , error ) {
23332338
23342339 var emptyRetribution HtlcRetribution
23352340
2336- theirDelay := uint32 (chanState .ChanCfgs .Remote .CsvDelay )
2341+ theirDelay := uint32 (
2342+ chanState .CommitChainEpochHistory .NormalizedParamsAt (
2343+ lntypes .Remote , stateNum ,
2344+ ).CsvDelay ,
2345+ )
23372346 isRemoteInitiator := ! chanState .IsInitiator
23382347
23392348 // We'll generate the original second level witness script now, as
@@ -2446,7 +2455,7 @@ func createHtlcRetribution(chanState *channeldb.OpenChannel,
24462455// see if these fields are present there. If they are not, then
24472456// ErrRevLogDataMissing is returned.
24482457func createBreachRetribution (revokedLog * channeldb.RevocationLog ,
2449- spendTx * wire.MsgTx , chanState * channeldb.OpenChannel ,
2458+ spendTx * wire.MsgTx , chanState * channeldb.OpenChannel , stateNum uint64 ,
24502459 keyRing * CommitmentKeyRing , commitmentSecret * btcec.PrivateKey ,
24512460 leaseExpiry uint32 ,
24522461 auxLeaves fn.Option [CommitAuxLeaves ]) (* BreachRetribution , int64 , int64 ,
@@ -2458,7 +2467,7 @@ func createBreachRetribution(revokedLog *channeldb.RevocationLog,
24582467 htlcRetributions := make ([]HtlcRetribution , len (revokedLog .HTLCEntries ))
24592468 for i , htlc := range revokedLog .HTLCEntries {
24602469 hr , err := createHtlcRetribution (
2461- chanState , keyRing , commitHash .Val ,
2470+ chanState , stateNum , keyRing , commitHash .Val ,
24622471 commitmentSecret , leaseExpiry , htlc , auxLeaves ,
24632472 )
24642473 if err != nil {
@@ -2562,8 +2571,8 @@ func createBreachRetribution(revokedLog *channeldb.RevocationLog,
25622571// BreachRetribution using a ChannelCommitment. Returns the constructed
25632572// retribution, our amount, their amount, and a possible non-nil error.
25642573func createBreachRetributionLegacy (revokedLog * channeldb.ChannelCommitment ,
2565- chanState * channeldb.OpenChannel , keyRing * CommitmentKeyRing ,
2566- commitmentSecret * btcec.PrivateKey ,
2574+ chanState * channeldb.OpenChannel , stateNum uint64 ,
2575+ keyRing * CommitmentKeyRing , commitmentSecret * btcec.PrivateKey ,
25672576 ourScript , theirScript input.ScriptDescriptor ,
25682577 leaseExpiry uint32 ) (* BreachRetribution , int64 , int64 , error ) {
25692578
@@ -2609,7 +2618,7 @@ func createBreachRetributionLegacy(revokedLog *channeldb.ChannelCommitment,
26092618 }
26102619
26112620 hr , err := createHtlcRetribution (
2612- chanState , keyRing , commitHash ,
2621+ chanState , stateNum , keyRing , commitHash ,
26132622 commitmentSecret , leaseExpiry , entry ,
26142623 fn .None [CommitAuxLeaves ](),
26152624 )
0 commit comments