From 8cc2e4afda3933d0123c04d388222c100c7e4630 Mon Sep 17 00:00:00 2001 From: Richard Myers Date: Tue, 27 Aug 2024 14:50:03 +0200 Subject: [PATCH] Add maxExcess_opt to ChannelParams in NodeParams This will be used by non-initiators when funding dual funded channels and splicing --- eclair-core/src/main/resources/reference.conf | 4 ++++ eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala | 5 ++++- .../main/scala/fr/acinq/eclair/channel/fsm/Channel.scala | 3 ++- .../src/test/scala/fr/acinq/eclair/TestConstants.scala | 6 ++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/eclair-core/src/main/resources/reference.conf b/eclair-core/src/main/resources/reference.conf index ca283b18b6..be0e6b722b 100644 --- a/eclair-core/src/main/resources/reference.conf +++ b/eclair-core/src/main/resources/reference.conf @@ -197,6 +197,10 @@ eclair { min-time-between-updates = 1 hour // minimum time between channel updates because the balance changed } + + // if > 0, excess channel funding up to this amount will be added to the amount contributed when funding + // dual-funded channels or splices. This is useful to avoid paying fees to add a small change output. + max-excess = 0 } balance-check-interval = 1 hour diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala b/eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala index 1c66625b53..68ef887768 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala @@ -476,6 +476,8 @@ object NodeParams extends Logging { val maxNoChannels = config.getInt("peer-connection.max-no-channels") require(maxNoChannels > 0, "peer-connection.max-no-channels must be > 0") + val maxExcess_opt = if (config.getInt("channel.max-excess") > 0) Some(Satoshi(config.getInt("channel.max-excess"))) else None + NodeParams( nodeKeyManager = nodeKeyManager, channelKeyManager = channelKeyManager, @@ -524,7 +526,8 @@ object NodeParams extends Logging { quiescenceTimeout = FiniteDuration(config.getDuration("channel.quiescence-timeout").getSeconds, TimeUnit.SECONDS), balanceThresholds = config.getConfigList("channel.channel-update.balance-thresholds").asScala.map(conf => BalanceThreshold(Satoshi(conf.getLong("available-sat")), Satoshi(conf.getLong("max-htlc-sat")))).toSeq, minTimeBetweenUpdates = FiniteDuration(config.getDuration("channel.channel-update.min-time-between-updates").getSeconds, TimeUnit.SECONDS), - acceptIncomingStaticRemoteKeyChannels = config.getBoolean("channel.accept-incoming-static-remote-key-channels") + acceptIncomingStaticRemoteKeyChannels = config.getBoolean("channel.accept-incoming-static-remote-key-channels"), + maxExcess_opt = maxExcess_opt, ), onChainFeeConf = OnChainFeeConf( feeTargets = feeTargets, diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala index 757c804031..356415856b 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala @@ -104,7 +104,8 @@ object Channel { quiescenceTimeout: FiniteDuration, balanceThresholds: Seq[BalanceThreshold], minTimeBetweenUpdates: FiniteDuration, - acceptIncomingStaticRemoteKeyChannels: Boolean) { + acceptIncomingStaticRemoteKeyChannels: Boolean, + maxExcess_opt: Option[Satoshi]) { require(0 <= maxHtlcValueInFlightPercent && maxHtlcValueInFlightPercent <= 100, "max-htlc-value-in-flight-percent must be between 0 and 100") require(balanceThresholds.sortBy(_.available) == balanceThresholds, "channel-update.balance-thresholds must be sorted by available-sat") diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala b/eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala index 6f520c1fb6..dde428f09c 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala @@ -144,7 +144,8 @@ object TestConstants { quiescenceTimeout = 2 minutes, balanceThresholds = Nil, minTimeBetweenUpdates = 0 hours, - acceptIncomingStaticRemoteKeyChannels = false + acceptIncomingStaticRemoteKeyChannels = false, + maxExcess_opt = None ), onChainFeeConf = OnChainFeeConf( feeTargets = FeeTargets(funding = ConfirmationPriority.Medium, closing = ConfirmationPriority.Medium), @@ -316,7 +317,8 @@ object TestConstants { quiescenceTimeout = 2 minutes, balanceThresholds = Nil, minTimeBetweenUpdates = 0 hour, - acceptIncomingStaticRemoteKeyChannels = false + acceptIncomingStaticRemoteKeyChannels = false, + maxExcess_opt = None ), onChainFeeConf = OnChainFeeConf( feeTargets = FeeTargets(funding = ConfirmationPriority.Medium, closing = ConfirmationPriority.Medium),