@@ -2102,7 +2102,12 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
21022102 return l .LocalAuxLeaf
21032103 },
21042104 )(auxResult .AuxLeaves )
2105- theirDelay := uint32 (chanState .ChanCfgs .Remote .CsvDelay )
2105+ theirDelay := uint32 (
2106+ chanState .CommitChainEpochHistory .NormalizedParamsAt (
2107+ lntypes .Remote , stateNum ,
2108+ ).CsvDelay ,
2109+ )
2110+
21062111 theirScript , err := CommitScriptToSelf (
21072112 chanState .ChanType , isRemoteInitiator , keyRing .ToLocalKey ,
21082113 keyRing .RevocationKey , theirDelay , leaseExpiry , localAuxLeaf ,
@@ -2122,7 +2127,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
21222127 // we need.
21232128 if revokedLog != nil {
21242129 br , ourAmt , theirAmt , err = createBreachRetribution (
2125- revokedLog , spendTx , chanState , keyRing ,
2130+ revokedLog , spendTx , chanState , stateNum , keyRing ,
21262131 commitmentSecret , leaseExpiry , auxResult .AuxLeaves ,
21272132 )
21282133 if err != nil {
@@ -2137,8 +2142,8 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
21372142 // data can still function. This branch can be deleted once we
21382143 // are confident that no legacy format is in use.
21392144 br , ourAmt , theirAmt , err = createBreachRetributionLegacy (
2140- revokedLogLegacy , chanState , keyRing , commitmentSecret ,
2141- ourScript , theirScript , leaseExpiry ,
2145+ revokedLogLegacy , chanState , stateNum , keyRing ,
2146+ commitmentSecret , ourScript , theirScript , leaseExpiry ,
21422147 )
21432148 if err != nil {
21442149 return nil , err
@@ -2317,15 +2322,19 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
23172322
23182323// createHtlcRetribution is a helper function to construct an HtlcRetribution
23192324// based on the passed params.
2320- func createHtlcRetribution (chanState * channeldb.OpenChannel ,
2325+ func createHtlcRetribution (chanState * channeldb.OpenChannel , stateNum uint64 ,
23212326 keyRing * CommitmentKeyRing , commitHash chainhash.Hash ,
23222327 commitmentSecret * btcec.PrivateKey , leaseExpiry uint32 ,
23232328 htlc * channeldb.HTLCEntry ,
23242329 auxLeaves fn.Option [CommitAuxLeaves ]) (HtlcRetribution , error ) {
23252330
23262331 var emptyRetribution HtlcRetribution
23272332
2328- theirDelay := uint32 (chanState .ChanCfgs .Remote .CsvDelay )
2333+ theirDelay := uint32 (
2334+ chanState .CommitChainEpochHistory .NormalizedParamsAt (
2335+ lntypes .Remote , stateNum ,
2336+ ).CsvDelay ,
2337+ )
23292338 isRemoteInitiator := ! chanState .IsInitiator
23302339
23312340 // We'll generate the original second level witness script now, as
@@ -2438,7 +2447,7 @@ func createHtlcRetribution(chanState *channeldb.OpenChannel,
24382447// see if these fields are present there. If they are not, then
24392448// ErrRevLogDataMissing is returned.
24402449func createBreachRetribution (revokedLog * channeldb.RevocationLog ,
2441- spendTx * wire.MsgTx , chanState * channeldb.OpenChannel ,
2450+ spendTx * wire.MsgTx , chanState * channeldb.OpenChannel , stateNum uint64 ,
24422451 keyRing * CommitmentKeyRing , commitmentSecret * btcec.PrivateKey ,
24432452 leaseExpiry uint32 ,
24442453 auxLeaves fn.Option [CommitAuxLeaves ]) (* BreachRetribution , int64 , int64 ,
@@ -2450,7 +2459,7 @@ func createBreachRetribution(revokedLog *channeldb.RevocationLog,
24502459 htlcRetributions := make ([]HtlcRetribution , len (revokedLog .HTLCEntries ))
24512460 for i , htlc := range revokedLog .HTLCEntries {
24522461 hr , err := createHtlcRetribution (
2453- chanState , keyRing , commitHash .Val ,
2462+ chanState , stateNum , keyRing , commitHash .Val ,
24542463 commitmentSecret , leaseExpiry , htlc , auxLeaves ,
24552464 )
24562465 if err != nil {
@@ -2554,8 +2563,8 @@ func createBreachRetribution(revokedLog *channeldb.RevocationLog,
25542563// BreachRetribution using a ChannelCommitment. Returns the constructed
25552564// retribution, our amount, their amount, and a possible non-nil error.
25562565func createBreachRetributionLegacy (revokedLog * channeldb.ChannelCommitment ,
2557- chanState * channeldb.OpenChannel , keyRing * CommitmentKeyRing ,
2558- commitmentSecret * btcec.PrivateKey ,
2566+ chanState * channeldb.OpenChannel , stateNum uint64 ,
2567+ keyRing * CommitmentKeyRing , commitmentSecret * btcec.PrivateKey ,
25592568 ourScript , theirScript input.ScriptDescriptor ,
25602569 leaseExpiry uint32 ) (* BreachRetribution , int64 , int64 , error ) {
25612570
@@ -2601,7 +2610,7 @@ func createBreachRetributionLegacy(revokedLog *channeldb.ChannelCommitment,
26012610 }
26022611
26032612 hr , err := createHtlcRetribution (
2604- chanState , keyRing , commitHash ,
2613+ chanState , stateNum , keyRing , commitHash ,
26052614 commitmentSecret , leaseExpiry , entry ,
26062615 fn .None [CommitAuxLeaves ](),
26072616 )
0 commit comments