@@ -112,9 +112,6 @@ object Channel {
112112 require(balanceThresholds.sortBy(_.available) == balanceThresholds, " channel-update.balance-thresholds must be sorted by available-sat" )
113113
114114 def minFundingSatoshis (flags : ChannelFlags ): Satoshi = if (flags.announceChannel) minFundingPublicSatoshis else minFundingPrivateSatoshis
115-
116- /** The number of confirmations required to be safe from reorgs is always scaled based on the amount at risk. */
117- def minDepthScaled (amount : Satoshi ): Int = ChannelParams .minDepthScaled(minDepth, amount)
118115 }
119116
120117 trait TxPublisherFactory {
@@ -320,14 +317,13 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
320317 // once, because at the next restore, the status of the funding tx will be "confirmed".
321318 ()
322319 }
323- watchFundingConfirmed(commitment.fundingTxId, Some (singleFundingMinDepth(data) ), herdDelay_opt)
320+ watchFundingConfirmed(commitment.fundingTxId, Some (nodeParams.channelConf.minDepth ), herdDelay_opt)
324321 case fundingTx : LocalFundingStatus .DualFundedUnconfirmedFundingTx =>
325322 publishFundingTx(fundingTx)
326- val minDepth_opt = data.commitments.params.minDepthDualFunding (nodeParams.channelConf.minDepth, fundingTx.sharedTx.tx )
323+ val minDepth_opt = data.commitments.params.minDepth (nodeParams.channelConf.minDepth)
327324 watchFundingConfirmed(fundingTx.sharedTx.txId, minDepth_opt, herdDelay_opt)
328325 case fundingTx : LocalFundingStatus .ZeroconfPublishedFundingTx =>
329- // This is a zero-conf channel, the min-depth isn't critical: we use the default.
330- watchFundingConfirmed(fundingTx.tx.txid, Some (nodeParams.channelConf.minDepth.toLong), herdDelay_opt)
326+ watchFundingConfirmed(fundingTx.tx.txid, Some (nodeParams.channelConf.minDepth), herdDelay_opt)
331327 case _ : LocalFundingStatus .ConfirmedFundingTx =>
332328 data match {
333329 case closing : DATA_CLOSING if Closing .nothingAtStake(closing) || Closing .isClosingTypeAlreadyKnown(closing).isDefined =>
@@ -612,7 +608,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
612608 // We don't have their tx_sigs, but they have ours, and could publish the funding tx without telling us.
613609 // That's why we move on immediately to the next step, and will update our unsigned funding tx when we
614610 // receive their tx_sigs.
615- val minDepth_opt = d.commitments.params.minDepthDualFunding (nodeParams.channelConf.minDepth, signingSession1.fundingTx.sharedTx.tx )
611+ val minDepth_opt = d.commitments.params.minDepth (nodeParams.channelConf.minDepth)
616612 watchFundingConfirmed(signingSession.fundingTx.txId, minDepth_opt, delay_opt = None )
617613 val commitments1 = d.commitments.add(signingSession1.commitment)
618614 val d1 = d.copy(commitments = commitments1, spliceStatus = SpliceStatus .NoSplice )
@@ -1349,7 +1345,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
13491345 rollbackFundingAttempt(signingSession.fundingTx.tx, previousTxs = Seq .empty) // no splice rbf yet
13501346 stay() using d.copy(spliceStatus = SpliceStatus .SpliceAborted ) sending TxAbort (d.channelId, f.getMessage)
13511347 case Right (signingSession1) =>
1352- val minDepth_opt = d.commitments.params.minDepthDualFunding (nodeParams.channelConf.minDepth, signingSession1.fundingTx.sharedTx.tx )
1348+ val minDepth_opt = d.commitments.params.minDepth (nodeParams.channelConf.minDepth)
13531349 watchFundingConfirmed(signingSession.fundingTx.txId, minDepth_opt, delay_opt = None )
13541350 val commitments1 = d.commitments.add(signingSession1.commitment)
13551351 val d1 = d.copy(commitments = commitments1, spliceStatus = SpliceStatus .NoSplice )
@@ -1368,7 +1364,6 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
13681364 val fundingStatus = LocalFundingStatus .ZeroconfPublishedFundingTx (w.tx, d.commitments.localFundingSigs(w.tx.txid), d.commitments.liquidityPurchase(w.tx.txid))
13691365 d.commitments.updateLocalFundingStatus(w.tx.txid, fundingStatus, d.lastAnnouncedFundingTxId_opt) match {
13701366 case Right ((commitments1, commitment)) =>
1371- // This is a zero-conf channel, the min-depth isn't critical: we use the default.
13721367 watchFundingConfirmed(w.tx.txid, Some (nodeParams.channelConf.minDepth), delay_opt = None )
13731368 maybeEmitEventsPostSplice(d.aliases, d.commitments, commitments1, d.lastAnnouncement_opt)
13741369 maybeUpdateMaxHtlcAmount(d.channelUpdate.htlcMaximumMsat, commitments1)
@@ -1960,7 +1955,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
19601955 d.commitments.resolveCommitment(tx) match {
19611956 case Some (commitment) =>
19621957 log.warning(" a commit tx for an older commitment has been published fundingTxId={} fundingTxIndex={}" , tx.txid, commitment.fundingTxIndex)
1963- blockchain ! WatchAlternativeCommitTxConfirmed (self, tx.txid, nodeParams.channelConf.minDepthScaled(commitment.capacity) )
1958+ blockchain ! WatchAlternativeCommitTxConfirmed (self, tx.txid, nodeParams.channelConf.minDepth )
19641959 stay()
19651960 case None =>
19661961 // This must be a former funding tx that has already been pruned, because watches are unordered.
@@ -2029,7 +2024,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
20292024 case Event (WatchOutputSpentTriggered (amount, tx), d : DATA_CLOSING ) =>
20302025 // one of the outputs of the local/remote/revoked commit was spent
20312026 // we just put a watch to be notified when it is confirmed
2032- blockchain ! WatchTxConfirmed (self, tx.txid, nodeParams.channelConf.minDepthScaled(amount) )
2027+ blockchain ! WatchTxConfirmed (self, tx.txid, nodeParams.channelConf.minDepth )
20332028 // when a remote or local commitment tx containing outgoing htlcs is published on the network,
20342029 // we watch it in order to extract payment preimage if funds are pulled by the counterparty
20352030 // we can then use these preimages to fulfill origin htlcs
@@ -2064,7 +2059,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
20642059 val (localCommitPublished1, claimHtlcTx_opt) = Closing .LocalClose .claimHtlcDelayedOutput(localCommitPublished, keyManager, d.commitments.latest, tx, nodeParams.currentBitcoinCoreFeerates, nodeParams.onChainFeeConf, d.finalScriptPubKey)
20652060 claimHtlcTx_opt.foreach(claimHtlcTx => {
20662061 txPublisher ! PublishFinalTx (claimHtlcTx, claimHtlcTx.fee, None )
2067- blockchain ! WatchTxConfirmed (self, claimHtlcTx.tx.txid, nodeParams.channelConf.minDepthScaled(claimHtlcTx.amountIn) , Some (RelativeDelay (tx.txid, d.commitments.params.remoteParams.toSelfDelay.toInt.toLong)))
2062+ blockchain ! WatchTxConfirmed (self, claimHtlcTx.tx.txid, nodeParams.channelConf.minDepth , Some (RelativeDelay (tx.txid, d.commitments.params.remoteParams.toSelfDelay.toInt.toLong)))
20682063 })
20692064 Closing .updateLocalCommitPublished(localCommitPublished1, tx)
20702065 }),
@@ -2841,7 +2836,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
28412836 } else {
28422837 // This is one of the transactions we published.
28432838 val closingTx = d.findClosingTx(tx).get
2844- blockchain ! WatchTxConfirmed (self, tx.txid, nodeParams.channelConf.minDepthScaled(closingTx.amountIn) )
2839+ blockchain ! WatchTxConfirmed (self, tx.txid, nodeParams.channelConf.minDepth )
28452840 stay()
28462841 }
28472842
@@ -2869,7 +2864,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
28692864 case Some (commitment) =>
28702865 log.warning(" a commit tx for an older commitment has been published fundingTxId={} fundingTxIndex={}" , tx.txid, commitment.fundingTxIndex)
28712866 // We watch the commitment tx, in the meantime we force close using the latest commitment.
2872- blockchain ! WatchAlternativeCommitTxConfirmed (self, tx.txid, nodeParams.channelConf.minDepthScaled(commitment.capacity) )
2867+ blockchain ! WatchAlternativeCommitTxConfirmed (self, tx.txid, nodeParams.channelConf.minDepth )
28732868 spendLocalCurrent(d)
28742869 case None =>
28752870 // This must be a former funding tx that has already been pruned, because watches are unordered.
0 commit comments