@@ -2102,7 +2102,12 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
2102
2102
return l .LocalAuxLeaf
2103
2103
},
2104
2104
)(auxResult .AuxLeaves )
2105
- theirDelay := uint32 (chanState .ChanCfgs .Remote .CsvDelay )
2105
+ theirDelay := uint32 (
2106
+ chanState .CommitChainEpochHistory .NormalizedParamsAt (
2107
+ lntypes .Remote , stateNum ,
2108
+ ).CsvDelay ,
2109
+ )
2110
+
2106
2111
theirScript , err := CommitScriptToSelf (
2107
2112
chanState .ChanType , isRemoteInitiator , keyRing .ToLocalKey ,
2108
2113
keyRing .RevocationKey , theirDelay , leaseExpiry , localAuxLeaf ,
@@ -2122,7 +2127,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
2122
2127
// we need.
2123
2128
if revokedLog != nil {
2124
2129
br , ourAmt , theirAmt , err = createBreachRetribution (
2125
- revokedLog , spendTx , chanState , keyRing ,
2130
+ revokedLog , spendTx , chanState , stateNum , keyRing ,
2126
2131
commitmentSecret , leaseExpiry , auxResult .AuxLeaves ,
2127
2132
)
2128
2133
if err != nil {
@@ -2137,8 +2142,8 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
2137
2142
// data can still function. This branch can be deleted once we
2138
2143
// are confident that no legacy format is in use.
2139
2144
br , ourAmt , theirAmt , err = createBreachRetributionLegacy (
2140
- revokedLogLegacy , chanState , keyRing , commitmentSecret ,
2141
- ourScript , theirScript , leaseExpiry ,
2145
+ revokedLogLegacy , chanState , stateNum , keyRing ,
2146
+ commitmentSecret , ourScript , theirScript , leaseExpiry ,
2142
2147
)
2143
2148
if err != nil {
2144
2149
return nil , err
@@ -2317,15 +2322,19 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
2317
2322
2318
2323
// createHtlcRetribution is a helper function to construct an HtlcRetribution
2319
2324
// based on the passed params.
2320
- func createHtlcRetribution (chanState * channeldb.OpenChannel ,
2325
+ func createHtlcRetribution (chanState * channeldb.OpenChannel , stateNum uint64 ,
2321
2326
keyRing * CommitmentKeyRing , commitHash chainhash.Hash ,
2322
2327
commitmentSecret * btcec.PrivateKey , leaseExpiry uint32 ,
2323
2328
htlc * channeldb.HTLCEntry ,
2324
2329
auxLeaves fn.Option [CommitAuxLeaves ]) (HtlcRetribution , error ) {
2325
2330
2326
2331
var emptyRetribution HtlcRetribution
2327
2332
2328
- theirDelay := uint32 (chanState .ChanCfgs .Remote .CsvDelay )
2333
+ theirDelay := uint32 (
2334
+ chanState .CommitChainEpochHistory .NormalizedParamsAt (
2335
+ lntypes .Remote , stateNum ,
2336
+ ).CsvDelay ,
2337
+ )
2329
2338
isRemoteInitiator := ! chanState .IsInitiator
2330
2339
2331
2340
// We'll generate the original second level witness script now, as
@@ -2438,7 +2447,7 @@ func createHtlcRetribution(chanState *channeldb.OpenChannel,
2438
2447
// see if these fields are present there. If they are not, then
2439
2448
// ErrRevLogDataMissing is returned.
2440
2449
func createBreachRetribution (revokedLog * channeldb.RevocationLog ,
2441
- spendTx * wire.MsgTx , chanState * channeldb.OpenChannel ,
2450
+ spendTx * wire.MsgTx , chanState * channeldb.OpenChannel , stateNum uint64 ,
2442
2451
keyRing * CommitmentKeyRing , commitmentSecret * btcec.PrivateKey ,
2443
2452
leaseExpiry uint32 ,
2444
2453
auxLeaves fn.Option [CommitAuxLeaves ]) (* BreachRetribution , int64 , int64 ,
@@ -2450,7 +2459,7 @@ func createBreachRetribution(revokedLog *channeldb.RevocationLog,
2450
2459
htlcRetributions := make ([]HtlcRetribution , len (revokedLog .HTLCEntries ))
2451
2460
for i , htlc := range revokedLog .HTLCEntries {
2452
2461
hr , err := createHtlcRetribution (
2453
- chanState , keyRing , commitHash .Val ,
2462
+ chanState , stateNum , keyRing , commitHash .Val ,
2454
2463
commitmentSecret , leaseExpiry , htlc , auxLeaves ,
2455
2464
)
2456
2465
if err != nil {
@@ -2554,8 +2563,8 @@ func createBreachRetribution(revokedLog *channeldb.RevocationLog,
2554
2563
// BreachRetribution using a ChannelCommitment. Returns the constructed
2555
2564
// retribution, our amount, their amount, and a possible non-nil error.
2556
2565
func 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 ,
2559
2568
ourScript , theirScript input.ScriptDescriptor ,
2560
2569
leaseExpiry uint32 ) (* BreachRetribution , int64 , int64 , error ) {
2561
2570
@@ -2601,7 +2610,7 @@ func createBreachRetributionLegacy(revokedLog *channeldb.ChannelCommitment,
2601
2610
}
2602
2611
2603
2612
hr , err := createHtlcRetribution (
2604
- chanState , keyRing , commitHash ,
2613
+ chanState , stateNum , keyRing , commitHash ,
2605
2614
commitmentSecret , leaseExpiry , entry ,
2606
2615
fn .None [CommitAuxLeaves ](),
2607
2616
)
0 commit comments