multi: add max local csv config option

To allow nodes more control over the amount of time that their funds
will be locked up, we add a MaxLocalCSVDelay option which sets the
maximum csv delay we will accept for all channels. We default to the
existing constant of 10000, and set a sane minimum on this value so that
clients cannot set unreasonably low maximum csv delays which will result
in their node rejecting all channels.
This commit is contained in:
carla
2020-10-29 11:29:53 +02:00
parent fbb430ad82
commit f4136decae
8 changed files with 235 additions and 19 deletions

View File

@@ -1,6 +1,10 @@
package lncfg
import "github.com/lightningnetwork/lnd/lnwire"
import (
"fmt"
"github.com/lightningnetwork/lnd/lnwire"
)
// Chain holds the configuration options for the daemon's chain settings.
type Chain struct {
@@ -16,9 +20,28 @@ type Chain struct {
DefaultNumChanConfs int `long:"defaultchanconfs" description:"The default number of confirmations a channel must have before it's considered open. If this is not set, we will scale the value according to the channel size."`
DefaultRemoteDelay int `long:"defaultremotedelay" description:"The default number of blocks we will require our channel counterparty to wait before accessing its funds in case of unilateral close. If this is not set, we will scale the value according to the channel size."`
MaxLocalDelay uint16 `long:"maxlocaldelay" description:"The maximum blocks we will allow our funds to be timelocked before accessing its funds in case of unilateral close. If a peer proposes a value greater than this, we will reject the channel."`
MinHTLCIn lnwire.MilliSatoshi `long:"minhtlc" description:"The smallest HTLC we are willing to accept on our channels, in millisatoshi"`
MinHTLCOut lnwire.MilliSatoshi `long:"minhtlcout" description:"The smallest HTLC we are willing to send out on our channels, in millisatoshi"`
BaseFee lnwire.MilliSatoshi `long:"basefee" description:"The base fee in millisatoshi we will charge for forwarding payments on our channels"`
FeeRate lnwire.MilliSatoshi `long:"feerate" description:"The fee rate used when forwarding payments on our channels. The total fee charged is basefee + (amount * feerate / 1000000), where amount is the forwarded amount."`
TimeLockDelta uint32 `long:"timelockdelta" description:"The CLTV delta we will subtract from a forwarded HTLC's timelock value"`
}
// Validate performs validation on our chain config.
func (c *Chain) Validate(minTimeLockDelta uint32, minDelay uint16) error {
if c.TimeLockDelta < minTimeLockDelta {
return fmt.Errorf("timelockdelta must be at least %v",
minTimeLockDelta)
}
// Check that our max local delay isn't set below some reasonable
// minimum value. We do this to prevent setting an unreasonably low
// delay, which would mean that the node would accept no channels.
if c.MaxLocalDelay < minDelay {
return fmt.Errorf("MaxLocalDelay must be at least: %v",
minDelay)
}
return nil
}