Skip to content

Commit 09fc936

Browse files
Rename maxHtlcAmount to maxHtlcValueInFlight in Commitments (#3131)
1 parent 43c3986 commit 09fc936

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ case class ChannelParams(channelId: ByteVector32,
3939
val remoteCommitParams: CommitParams = CommitParams(remoteParams.dustLimit, remoteParams.htlcMinimum, remoteParams.maxHtlcValueInFlightMsat, remoteParams.maxAcceptedHtlcs, localParams.toRemoteDelay)
4040

4141
// We can safely cast to millisatoshis since we verify that it's less than a valid millisatoshi amount.
42-
val maxHtlcAmount: MilliSatoshi = Seq(localParams.maxHtlcValueInFlightMsat, remoteParams.maxHtlcValueInFlightMsat, UInt64(MilliSatoshi.MaxMoney.toLong)).min.toBigInt.toLong.msat
42+
val maxHtlcValueInFlight: MilliSatoshi = Seq(localParams.maxHtlcValueInFlightMsat, remoteParams.maxHtlcValueInFlightMsat, UInt64(MilliSatoshi.MaxMoney.toLong)).min.toBigInt.toLong.msat
4343

4444
// If we've set the 0-conf feature bit for this peer, we will always use 0-conf with them.
4545
val zeroConf: Boolean = localParams.initFeatures.hasFeature(Features.ZeroConf)
@@ -508,7 +508,7 @@ case class Commitment(fundingTxIndex: Long,
508508
// We apply local *and* remote restrictions, to ensure both peers are happy with the resulting number of HTLCs.
509509
// NB: we need the `toSeq` because otherwise duplicate amountMsat would be removed (since outgoingHtlcs is a Set).
510510
val htlcValueInFlight = outgoingHtlcs.toSeq.map(_.amountMsat).sum
511-
val allowedHtlcValueInFlight = UInt64(params.maxHtlcAmount.toLong)
511+
val allowedHtlcValueInFlight = UInt64(params.maxHtlcValueInFlight.toLong)
512512
if (allowedHtlcValueInFlight < htlcValueInFlight) {
513513
return Left(HtlcValueTooHighInFlight(params.channelId, maximum = allowedHtlcValueInFlight, actual = htlcValueInFlight))
514514
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,17 +368,17 @@ object Helpers {
368368
def maxHtlcAmount(nodeParams: NodeParams, commitments: Commitments): MilliSatoshi = {
369369
if (!commitments.announceChannel) {
370370
// The channel is private, let's not change the channel update needlessly.
371-
return commitments.channelParams.maxHtlcAmount
371+
return commitments.channelParams.maxHtlcValueInFlight
372372
}
373373
for (balanceThreshold <- nodeParams.channelConf.balanceThresholds) {
374374
if (commitments.availableBalanceForSend <= balanceThreshold.available) {
375375
// Our maximum HTLC amount must always be greater than htlc_minimum_msat.
376376
val allowedHtlcAmount = Seq(balanceThreshold.maxHtlcAmount.toMilliSatoshi, commitments.channelParams.localCommitParams.htlcMinimum, commitments.channelParams.remoteCommitParams.htlcMinimum).max
377377
// But it cannot exceed the channel's max_htlc_value_in_flight_msat.
378-
return allowedHtlcAmount.min(commitments.channelParams.maxHtlcAmount)
378+
return allowedHtlcAmount.min(commitments.channelParams.maxHtlcValueInFlight)
379379
}
380380
}
381-
commitments.channelParams.maxHtlcAmount
381+
commitments.channelParams.maxHtlcValueInFlight
382382
}
383383

384384
def getRelayFees(nodeParams: NodeParams, remoteNodeId: PublicKey, announceChannel: Boolean): RelayFees = {

eclair-core/src/main/scala/fr/acinq/eclair/reputation/Reputation.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ object Reputation {
135135
// We want to allow some small HTLCs but still keep slots for larger ones.
136136
// We never want to reject HTLCs of size above `maxHtlcAmount / maxAcceptedHtlcs` as too small because we want to allow filling all the slots with HTLCs of equal sizes.
137137
// We use exponentially spaced thresholds in between.
138-
if (amountMsat.toLong < 1 || amountMsat.toLong.toDouble < math.pow(params.maxHtlcAmount.toLong.toDouble / maxAcceptedHtlcs, i / maxAcceptedHtlcs)) {
138+
if (amountMsat.toLong < 1 || amountMsat.toLong.toDouble < math.pow(params.maxHtlcValueInFlight.toLong.toDouble / maxAcceptedHtlcs, i / maxAcceptedHtlcs)) {
139139
return Left(TooManySmallHtlcs(params.channelId, number = i + 1, below = amountMsat))
140140
}
141141
}
142142

143143
val htlcValueInFlight = outgoingHtlcs.map(_.amountMsat).sum
144144
val slotsOccupancy = outgoingHtlcs.size.toDouble / maxAcceptedHtlcs
145-
val valueOccupancy = htlcValueInFlight.toLong.toDouble / params.maxHtlcAmount.toLong.toDouble
145+
val valueOccupancy = htlcValueInFlight.toLong.toDouble / params.maxHtlcValueInFlight.toLong.toDouble
146146
val occupancy = slotsOccupancy max valueOccupancy
147147
// Because there are only 8 endorsement levels, the highest endorsement corresponds to a confidence between 87.5% and 100%.
148148
// So even for well-behaved peers setting the highest endorsement we still expect a confidence of less than 93.75%.

0 commit comments

Comments
 (0)