1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-22 22:25:26 +01:00

Simplify dual-funded min-depth calculation (#2758)

We added an override and an optional paramter to be used in feature
branches, but it was actually unnecessary.
This commit is contained in:
Bastien Teinturier 2023-09-29 14:08:01 +02:00 committed by GitHub
parent e199d15d9f
commit e4103a2a65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,26 +81,15 @@ case class ChannelParams(channelId: ByteVector32,
* When using dual funding or splices, we wait for multiple confirmations even if we're the initiator because:
* - our peer may also contribute to the funding transaction, even if they don't contribute to the channel funding amount
* - even if they don't, we may RBF the transaction and don't want to handle reorgs
*
* @param fundingAmount total funding amount of the channel.
* @param remoteContributes_opt true if the remote has the ability to double-spend the transaction (even if they're
* not contributing to the shared funding amount). Should be empty if we don't know yet
* if the remote will contribute to the shared transaction.
*/
def minDepthDualFunding(defaultMinDepth: Int, fundingAmount: Satoshi, remoteContributes_opt: Option[Boolean] = None): Option[Long] = {
def minDepthDualFunding(defaultMinDepth: Int, sharedTx: SharedTransaction): Option[Long] = {
if (localParams.initFeatures.hasFeature(Features.ZeroConf)) {
None
} else {
Some(ChannelParams.minDepthScaled(defaultMinDepth, fundingAmount))
Some(ChannelParams.minDepthScaled(defaultMinDepth, sharedTx.sharedOutput.amount))
}
}
/**
* When the shared transaction has been built and we know exactly how our peer is going to contribute, we can compute
* the real min_depth that we are going to actually use.
*/
def minDepthDualFunding(defaultMinDepth: Int, sharedTx: SharedTransaction): Option[Long] = minDepthDualFunding(defaultMinDepth, sharedTx.sharedOutput.amount, Some(sharedTx.remoteInputs.nonEmpty))
/** Channel reserve that applies to our funds. */
def localChannelReserveForCapacity(capacity: Satoshi, isSplice: Boolean): Satoshi = if (channelFeatures.hasFeature(Features.DualFunding) || isSplice) {
(capacity / 100).max(remoteParams.dustLimit)