lnwallet: cap value reserved for anchor fee bumping

We cap the maximum value we'll reserve for anchor channel fee bumping at
10 times the per-channel amount such that nodes with a high number of
channels don't have to keep around a very large amount for the unlikely
scanario that they all close at the same time.
This commit is contained in:
Johan T. Halseth 2021-05-06 13:24:43 +02:00
parent ba5aaec632
commit a0b6a0b00b
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -39,6 +39,13 @@ const (
// TODO(halseth): update constant to target a specific commit size at // TODO(halseth): update constant to target a specific commit size at
// set fee rate. // set fee rate.
anchorChanReservedValue = btcutil.Amount(10_000) anchorChanReservedValue = btcutil.Amount(10_000)
// maxAnchorChanReservedValue is the maximum value we'll reserve for
// anchor channel fee bumping. We cap it at 10 times the per-channel
// amount such that nodes with a high number of channels don't have to
// keep around a very large amount for the unlikely scenario that they
// all close at the same time.
maxAnchorChanReservedValue = 10 * anchorChanReservedValue
) )
var ( var (
@ -1000,6 +1007,9 @@ func (l *LightningWallet) CheckReservedValue(in []wire.OutPoint,
// We reserve a given amount for each anchor channel. // We reserve a given amount for each anchor channel.
reserved := btcutil.Amount(numAnchorChans) * anchorChanReservedValue reserved := btcutil.Amount(numAnchorChans) * anchorChanReservedValue
if reserved > maxAnchorChanReservedValue {
reserved = maxAnchorChanReservedValue
}
if walletBalance < reserved { if walletBalance < reserved {
walletLog.Debugf("Reserved value=%v above final "+ walletLog.Debugf("Reserved value=%v above final "+