Skip to content

Commit b76acc6

Browse files
committed
Fix fee mismatch without htlc
We allow disagreeing on fees while the channel doesn't contain any htlc, because no funds can be at risk in that case. But we used the latest signed fee when adding a new HTLC, whereas we must also take into account the latest proposed (unsigned) fee.
1 parent 5be613d commit b76acc6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,10 @@ object Commitments {
276276

277277
// we allowed mismatches between our feerates and our remote's as long as commitments didn't contain any HTLC at risk
278278
// we need to verify that we're not disagreeing on feerates anymore before offering new HTLCs
279+
// NB: there may be a pending update_fee that hasn't been signed yet that needs to be taken into account
280+
val currentFeeratePerKw = commitments.remoteChanges.proposed.collect { case f: UpdateFee => f.feeratePerKw }.lastOption.getOrElse(commitments.localCommit.spec.feeratePerKw)
279281
val localFeeratePerKw = feeConf.getCommitmentFeerate(commitments.channelVersion, commitments.capacity, None)
280-
if (feeConf.maxFeerateMismatchFor(commitments.remoteNodeId).isFeeDiffTooHigh(commitments.channelVersion, localFeeratePerKw, commitments.localCommit.spec.feeratePerKw)) {
282+
if (feeConf.maxFeerateMismatchFor(commitments.remoteNodeId).isFeeDiffTooHigh(commitments.channelVersion, localFeeratePerKw, currentFeeratePerKw)) {
281283
return Left(FeerateTooDifferent(commitments.channelId, localFeeratePerKw = localFeeratePerKw, remoteFeeratePerKw = commitments.localCommit.spec.feeratePerKw))
282284
}
283285

@@ -337,8 +339,10 @@ object Commitments {
337339

338340
// we allowed mismatches between our feerates and our remote's as long as commitments didn't contain any HTLC at risk
339341
// we need to verify that we're not disagreeing on feerates anymore before accepting new HTLCs
342+
// NB: there may be a pending update_fee that hasn't been signed yet that needs to be taken into account
343+
val currentFeeratePerKw = commitments.remoteChanges.proposed.collect { case f: UpdateFee => f.feeratePerKw }.lastOption.getOrElse(commitments.localCommit.spec.feeratePerKw)
340344
val localFeeratePerKw = feeConf.getCommitmentFeerate(commitments.channelVersion, commitments.capacity, None)
341-
if (feeConf.maxFeerateMismatchFor(commitments.remoteNodeId).isFeeDiffTooHigh(commitments.channelVersion, localFeeratePerKw, commitments.localCommit.spec.feeratePerKw)) {
345+
if (feeConf.maxFeerateMismatchFor(commitments.remoteNodeId).isFeeDiffTooHigh(commitments.channelVersion, localFeeratePerKw, currentFeeratePerKw)) {
342346
return Left(FeerateTooDifferent(commitments.channelId, localFeeratePerKw = localFeeratePerKw, remoteFeeratePerKw = commitments.localCommit.spec.feeratePerKw))
343347
}
344348

0 commit comments

Comments
 (0)