From a0b6a0b00ba8306f55535a058f528641dbec873c Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 6 May 2021 13:24:43 +0200 Subject: [PATCH] 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. --- lnwallet/wallet.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lnwallet/wallet.go b/lnwallet/wallet.go index 6d28f91d..dc6d6838 100644 --- a/lnwallet/wallet.go +++ b/lnwallet/wallet.go @@ -39,6 +39,13 @@ const ( // TODO(halseth): update constant to target a specific commit size at // set fee rate. 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 ( @@ -1000,6 +1007,9 @@ func (l *LightningWallet) CheckReservedValue(in []wire.OutPoint, // We reserve a given amount for each anchor channel. reserved := btcutil.Amount(numAnchorChans) * anchorChanReservedValue + if reserved > maxAnchorChanReservedValue { + reserved = maxAnchorChanReservedValue + } if walletBalance < reserved { walletLog.Debugf("Reserved value=%v above final "+