Skip to content

Commit 7f2e484

Browse files
committed
Lower minimum remote dust limit
We are slowly dropping support for non-segwit outputs, as proposed in lightning/bolts#894 We can thus safely allow dust limits all the way down to 354 satoshis.
1 parent c846781 commit 7f2e484

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ object NodeParams extends Logging {
233233

234234
val dustLimitSatoshis = Satoshi(config.getLong("dust-limit-satoshis"))
235235
if (chainHash == Block.LivenetGenesisBlock.hash) {
236-
require(dustLimitSatoshis >= Channel.MIN_DUSTLIMIT, s"dust limit must be greater than ${Channel.MIN_DUSTLIMIT}")
236+
require(dustLimitSatoshis >= Channel.MIN_DUST_LIMIT, s"dust limit must be greater than ${Channel.MIN_DUST_LIMIT}")
237237
}
238238

239239
val htlcMinimum = MilliSatoshi(config.getInt("htlc-minimum-msat"))

eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ object Channel {
7979
val MAX_FUNDING: Satoshi = 16777216 sat // = 2^24
8080
val MAX_ACCEPTED_HTLCS = 483
8181

82-
// we don't want the counterparty to use a dust limit lower than that, because they wouldn't only hurt themselves we may need them to publish their commit tx in certain cases (backup/restore)
83-
val MIN_DUSTLIMIT: Satoshi = 546 sat
82+
// We may need to rely on our peer's commit tx in certain cases (backup/restore) so we must ensure their transactions
83+
// can propagate through the bitcoin network (assuming bitcoin core nodes with default policies).
84+
// The various dust limits enforced by the bitcoin network are summarized here:
85+
// https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#dust-limits
86+
// A dust limit of 354 sat ensures all segwit outputs will relay with default relay policies.
87+
val MIN_DUST_LIMIT: Satoshi = 354 sat
8488

8589
// we won't exchange more than this many signatures when negotiating the closing fee
8690
val MAX_NEGOTIATION_ITERATIONS = 20

eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ object Helpers {
138138
if (nodeParams.onChainFeeConf.feerateToleranceFor(remoteNodeId).isFeeDiffTooHigh(channelType, localFeeratePerKw, open.feeratePerKw)) return Left(FeerateTooDifferent(open.temporaryChannelId, localFeeratePerKw, open.feeratePerKw))
139139
// only enforce dust limit check on mainnet
140140
if (nodeParams.chainHash == Block.LivenetGenesisBlock.hash) {
141-
if (open.dustLimitSatoshis < Channel.MIN_DUSTLIMIT) return Left(DustLimitTooSmall(open.temporaryChannelId, open.dustLimitSatoshis, Channel.MIN_DUSTLIMIT))
141+
if (open.dustLimitSatoshis < Channel.MIN_DUST_LIMIT) return Left(DustLimitTooSmall(open.temporaryChannelId, open.dustLimitSatoshis, Channel.MIN_DUST_LIMIT))
142142
}
143143

144144
// we don't check that the funder's amount for the initial commitment transaction is sufficient for full fee payment
@@ -169,7 +169,7 @@ object Helpers {
169169
if (accept.maxAcceptedHtlcs > Channel.MAX_ACCEPTED_HTLCS) return Left(InvalidMaxAcceptedHtlcs(accept.temporaryChannelId, accept.maxAcceptedHtlcs, Channel.MAX_ACCEPTED_HTLCS))
170170
// only enforce dust limit check on mainnet
171171
if (nodeParams.chainHash == Block.LivenetGenesisBlock.hash) {
172-
if (accept.dustLimitSatoshis < Channel.MIN_DUSTLIMIT) return Left(DustLimitTooSmall(accept.temporaryChannelId, accept.dustLimitSatoshis, Channel.MIN_DUSTLIMIT))
172+
if (accept.dustLimitSatoshis < Channel.MIN_DUST_LIMIT) return Left(DustLimitTooSmall(accept.temporaryChannelId, accept.dustLimitSatoshis, Channel.MIN_DUST_LIMIT))
173173
}
174174

175175
if (accept.dustLimitSatoshis > nodeParams.maxRemoteDustLimit) return Left(DustLimitTooLarge(open.temporaryChannelId, accept.dustLimitSatoshis, nodeParams.maxRemoteDustLimit))

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForAcceptChannelStateSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS
177177
test("recv AcceptChannel (dust limit too low)", Tag("mainnet")) { f =>
178178
import f._
179179
val accept = bob2alice.expectMsgType[AcceptChannel]
180-
// we don't want their dust limit to be below 546
181-
val lowDustLimitSatoshis = 545.sat
180+
// we don't want their dust limit to be below 354
181+
val lowDustLimitSatoshis = 353.sat
182182
alice ! accept.copy(dustLimitSatoshis = lowDustLimitSatoshis)
183183
val error = alice2bob.expectMsgType[Error]
184-
assert(error === Error(accept.temporaryChannelId, DustLimitTooSmall(accept.temporaryChannelId, lowDustLimitSatoshis, Channel.MIN_DUSTLIMIT).getMessage))
184+
assert(error === Error(accept.temporaryChannelId, DustLimitTooSmall(accept.temporaryChannelId, lowDustLimitSatoshis, Channel.MIN_DUST_LIMIT).getMessage))
185185
awaitCond(alice.stateName == CLOSED)
186186
}
187187

0 commit comments

Comments
 (0)