Skip to content

Commit

Permalink
Take min feerate into account for recommended fees (#2918)
Browse files Browse the repository at this point in the history
Independently of target and tolerance ratios, transactions must be
publishable in our local mempool. We must be careful that fee ranges
stay above this min fee level.

In theory we shouldn't need to care about the upper range, but I'm not
sure that, depending on the fee estimator, the min fee is always lower
than arbitrary block targets.
  • Loading branch information
pm47 authored Oct 2, 2024
1 parent 5e9d8c3 commit 11b6a52
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,23 @@ case class NodeParams(nodeKeyManager: NodeKeyManager,

/** Returns the feerates we'd like our peer to use when funding channels. */
def recommendedFeerates(remoteNodeId: PublicKey, localFeatures: Features[InitFeature], remoteFeatures: Features[InitFeature]): RecommendedFeerates = {
// Independently of target and tolerance ratios, our transactions must be publishable in our local mempool
val minimumFeerate = currentBitcoinCoreFeerates.minimum
val feerateTolerance = onChainFeeConf.feerateToleranceFor(remoteNodeId)
val fundingFeerate = onChainFeeConf.getFundingFeerate(currentBitcoinCoreFeerates)
val fundingRange = RecommendedFeeratesTlv.FundingFeerateRange(
min = fundingFeerate * feerateTolerance.ratioLow,
max = fundingFeerate * feerateTolerance.ratioHigh,
min = (fundingFeerate * feerateTolerance.ratioLow).max(minimumFeerate),
max = (fundingFeerate * feerateTolerance.ratioHigh).max(minimumFeerate),
)
// We use the most likely commitment format, even though there is no guarantee that this is the one that will be used.
val commitmentFormat = ChannelTypes.defaultFromFeatures(localFeatures, remoteFeatures, announceChannel = false).commitmentFormat
val commitmentFeerate = onChainFeeConf.getCommitmentFeerate(currentBitcoinCoreFeerates, remoteNodeId, commitmentFormat, channelConf.minFundingPrivateSatoshis)
val commitmentRange = RecommendedFeeratesTlv.CommitmentFeerateRange(
min = commitmentFeerate * feerateTolerance.ratioLow,
max = commitmentFormat match {
min = (commitmentFeerate * feerateTolerance.ratioLow).max(minimumFeerate),
max = (commitmentFormat match {
case Transactions.DefaultCommitmentFormat => commitmentFeerate * feerateTolerance.ratioHigh
case _: Transactions.AnchorOutputsCommitmentFormat => (commitmentFeerate * feerateTolerance.ratioHigh).max(feerateTolerance.anchorOutputMaxCommitFeerate)
},
}).max(minimumFeerate),
)
RecommendedFeerates(chainHash, fundingFeerate, commitmentFeerate, TlvStream(fundingRange, commitmentRange))
}
Expand Down

0 comments on commit 11b6a52

Please sign in to comment.