Skip to content

Commit

Permalink
lnwallet: Change MaxFee calculation.
Browse files Browse the repository at this point in the history
When determining the max fee rate of a channel we used to scale
the fee rate depending on our available local balance on this channel.
This lead to a special case that if a channel would be drained we
could especially decrease the fee rate even down to the fee floor.
Now we make sure that our max fee rate will not be lower than the
old fee rate to make sure in case our channel is locally drained
we do not continue to decrease fees too low.
  • Loading branch information
ziggie1984 committed Jul 21, 2023
1 parent 430167e commit 00ddb22
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lnwallet/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -7346,7 +7346,12 @@ func (lc *LightningChannel) MaxFeeRate(maxAllocation float64) chainfee.SatPerKWe
// baseBalance is the maximum amount available for us to spend on fees.
baseBalance := availableBalance.ToSatoshis() + oldFee

// In case our local channel balance is drained, we make sure we do not
// decrease the fee rate below the old fee rate. This could lead to a
// scenario where we lower the commitment fee rate as low as the fee
// floor although current fee rates are way higher.
maxFee := float64(baseBalance) * maxAllocation
maxFee = math.Max(maxFee, float64(oldFee))

// Ensure the fee rate doesn't dip below the fee floor.
maxFeeRate := maxFee / (float64(weight) / 1000)
Expand Down

0 comments on commit 00ddb22

Please sign in to comment.