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 committed 2020-11-04 13:55:37 +02:00
1 parent fbb430ad82
commit f4136decae
8 files changed
+235 -19

No files matched your search

+14 -6
View File
@@ -112,6 +112,11 @@ const (
// concurrent HTLCs the remote party may add to commitment transactions.
// This value can be overridden with --default-remote-max-htlcs.
defaultRemoteMaxHtlcs = 483
// defaultMaxLocalCSVDelay is the maximum delay we accept on our
// commitment output.
// TODO(halseth): find a more scientific choice of value.
defaultMaxLocalCSVDelay = 10000
)
var (
@@ -344,6 +349,7 @@ func DefaultConfig() Config {
BaseFee: chainreg.DefaultBitcoinBaseFeeMSat,
FeeRate: chainreg.DefaultBitcoinFeeRate,
TimeLockDelta: chainreg.DefaultBitcoinTimeLockDelta,
MaxLocalDelay: defaultMaxLocalCSVDelay,
Node: "btcd",
},
BtcdMode: &lncfg.Btcd{
@@ -362,6 +368,7 @@ func DefaultConfig() Config {
BaseFee: chainreg.DefaultLitecoinBaseFeeMSat,
FeeRate: chainreg.DefaultLitecoinFeeRate,
TimeLockDelta: chainreg.DefaultLitecoinTimeLockDelta,
MaxLocalDelay: defaultMaxLocalCSVDelay,
Node: "ltcd",
},
LtcdMode: &lncfg.Btcd{
@@ -822,10 +829,11 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
"litecoin.active must be set to 1 (true)", funcName)
case cfg.Litecoin.Active:
if cfg.Litecoin.TimeLockDelta < minTimeLockDelta {
return nil, fmt.Errorf("timelockdelta must be at least %v",
minTimeLockDelta)
err := cfg.Litecoin.Validate(minTimeLockDelta, minLtcRemoteDelay)
if err != nil {
return nil, err
}
// Multiple networks can't be selected simultaneously. Count
// number of network flags passed; assign active network params
// while we're at it.
@@ -946,9 +954,9 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
return nil, err
}
if cfg.Bitcoin.TimeLockDelta < minTimeLockDelta {
return nil, fmt.Errorf("timelockdelta must be at least %v",
minTimeLockDelta)
err := cfg.Bitcoin.Validate(minTimeLockDelta, minBtcRemoteDelay)
if err != nil {
return nil, err
}
switch cfg.Bitcoin.Node {