@@ -32,7 +32,8 @@ import fr.acinq.eclair.blockchain.bitcoind.rpc.ExtendedBitcoinClient
32
32
import fr .acinq .eclair .channel .Helpers .{Closing , Funding }
33
33
import fr .acinq .eclair .channel .Monitoring .Metrics .ProcessMessage
34
34
import fr .acinq .eclair .channel .Monitoring .{Metrics , Tags }
35
- import fr .acinq .eclair .channel .TxPublisher .{PublishRawTx , PublishTx , SetChannelId , SignAndPublishTx }
35
+ import fr .acinq .eclair .channel .publish .TxPublisher
36
+ import fr .acinq .eclair .channel .publish .TxPublisher .{PublishRawTx , PublishReplaceableTx , PublishTx , SetChannelId }
36
37
import fr .acinq .eclair .crypto .ShaChain
37
38
import fr .acinq .eclair .crypto .keymanager .ChannelKeyManager
38
39
import fr .acinq .eclair .db .DbEventHandler .ChannelEvent .EventType
@@ -63,7 +64,7 @@ object Channel {
63
64
64
65
case class SimpleTxPublisherFactory (nodeParams : NodeParams , watcher : typed.ActorRef [ZmqWatcher .Command ], bitcoinClient : ExtendedBitcoinClient ) extends TxPublisherFactory {
65
66
override def spawnTxPublisher (context : ActorContext , remoteNodeId : PublicKey ): typed.ActorRef [TxPublisher .Command ] = {
66
- context.spawn(Behaviors .supervise(TxPublisher (nodeParams, remoteNodeId, watcher , bitcoinClient)).onFailure(typed.SupervisorStrategy .restart), " tx-publisher" )
67
+ context.spawn(Behaviors .supervise(TxPublisher (nodeParams, remoteNodeId, TxPublisher . SimpleChildFactory (nodeParams , bitcoinClient, watcher) )).onFailure(typed.SupervisorStrategy .restart), " tx-publisher" )
67
68
}
68
69
}
69
70
@@ -1380,7 +1381,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
1380
1381
}
1381
1382
val revokedCommitPublished1 = d.revokedCommitPublished.map { rev =>
1382
1383
val (rev1, penaltyTxs) = Closing .claimRevokedHtlcTxOutputs(keyManager, d.commitments, rev, tx, nodeParams.onChainFeeConf.feeEstimator)
1383
- penaltyTxs.foreach(claimTx => txPublisher ! PublishRawTx (claimTx))
1384
+ penaltyTxs.foreach(claimTx => txPublisher ! PublishRawTx (claimTx, None ))
1384
1385
penaltyTxs.foreach(claimTx => blockchain ! WatchOutputSpent (self, tx.txid, claimTx.input.outPoint.index.toInt, hints = Set (claimTx.tx.txid)))
1385
1386
rev1
1386
1387
}
@@ -1394,7 +1395,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
1394
1395
// If the tx is one of our HTLC txs, we now publish a 3rd-stage claim-htlc-tx that claims its output.
1395
1396
val (localCommitPublished1, claimHtlcTx_opt) = Closing .claimLocalCommitHtlcTxOutput(localCommitPublished, keyManager, d.commitments, tx, nodeParams.onChainFeeConf.feeEstimator, nodeParams.onChainFeeConf.feeTargets)
1396
1397
claimHtlcTx_opt.foreach(claimHtlcTx => {
1397
- txPublisher ! PublishRawTx (claimHtlcTx)
1398
+ txPublisher ! PublishRawTx (claimHtlcTx, None )
1398
1399
blockchain ! WatchTxConfirmed (self, claimHtlcTx.tx.txid, nodeParams.minDepthBlocks)
1399
1400
})
1400
1401
Closing .updateLocalCommitPublished(localCommitPublished1, tx)
@@ -2046,7 +2047,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
2046
2047
case Some (fundingTx) =>
2047
2048
// if we are funder, we never give up
2048
2049
log.info(s " republishing the funding tx... " )
2049
- txPublisher ! PublishRawTx (fundingTx, " funding-tx" )
2050
+ txPublisher ! PublishRawTx (fundingTx, fundingTx.txIn.head.outPoint, " funding-tx" , None )
2050
2051
// we also check if the funding tx has been double-spent
2051
2052
checkDoubleSpent(fundingTx)
2052
2053
context.system.scheduler.scheduleOnce(1 day, blockchain.toClassic, GetTxWithMeta (self, txid))
@@ -2199,7 +2200,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
2199
2200
}
2200
2201
2201
2202
private def doPublish (closingTx : ClosingTx ): Unit = {
2202
- txPublisher ! PublishRawTx (closingTx)
2203
+ txPublisher ! PublishRawTx (closingTx, None )
2203
2204
blockchain ! WatchTxConfirmed (self, closingTx.tx.txid, nodeParams.minDepthBlocks)
2204
2205
}
2205
2206
@@ -2229,12 +2230,9 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
2229
2230
* This helper method will publish txs only if they haven't yet reached minDepth
2230
2231
*/
2231
2232
private def publishIfNeeded (txs : Iterable [PublishTx ], irrevocablySpent : Map [OutPoint , Transaction ]): Unit = {
2232
- val (skip, process) = txs.partition(publishTx => Closing .inputsAlreadySpent(publishTx.tx, irrevocablySpent))
2233
- process.foreach { publishTx =>
2234
- log.info(s " publishing txid= ${publishTx.tx.txid}" )
2235
- txPublisher ! publishTx
2236
- }
2237
- skip.foreach(publishTx => log.info(s " no need to republish txid= ${publishTx.tx.txid}, it has already been confirmed " ))
2233
+ val (skip, process) = txs.partition(publishTx => Closing .inputAlreadySpent(publishTx.input, irrevocablySpent))
2234
+ process.foreach { publishTx => txPublisher ! publishTx }
2235
+ skip.foreach(publishTx => log.info(" no need to republish tx spending {}:{}, it has already been confirmed" , publishTx.input.txid, publishTx.input.index))
2238
2236
}
2239
2237
2240
2238
/**
@@ -2264,13 +2262,15 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
2264
2262
private def doPublish (localCommitPublished : LocalCommitPublished , commitments : Commitments ): Unit = {
2265
2263
import localCommitPublished ._
2266
2264
2265
+ val commitInput = commitments.commitInput.outPoint
2267
2266
val publishQueue = commitments.commitmentFormat match {
2268
2267
case Transactions .DefaultCommitmentFormat =>
2269
- List (PublishRawTx (commitTx, " commit-tx" )) ++ (claimMainDelayedOutputTx ++ htlcTxs.values.flatten ++ claimHtlcDelayedTxs).map(tx => PublishRawTx (tx))
2268
+ val redeemableHtlcTxs = htlcTxs.values.flatten.map(tx => PublishRawTx (tx, Some (commitTx.txid)))
2269
+ List (PublishRawTx (commitTx, commitInput, " commit-tx" , None )) ++ (claimMainDelayedOutputTx.map(tx => PublishRawTx (tx, None )) ++ redeemableHtlcTxs ++ claimHtlcDelayedTxs.map(tx => PublishRawTx (tx, None )))
2270
2270
case Transactions .AnchorOutputsCommitmentFormat =>
2271
- val claimLocalAnchor = claimAnchorTxs.collect { case tx : Transactions .ClaimLocalAnchorOutputTx => SignAndPublishTx (tx, commitments) }
2272
- val redeemableHtlcTxs = htlcTxs.values.collect { case Some (tx) => SignAndPublishTx (tx, commitments) }
2273
- List (PublishRawTx (commitTx, " commit-tx" )) ++ claimLocalAnchor ++ claimMainDelayedOutputTx.map(tx => PublishRawTx (tx)) ++ redeemableHtlcTxs ++ claimHtlcDelayedTxs.map(tx => PublishRawTx (tx))
2271
+ val claimLocalAnchor = claimAnchorTxs.collect { case tx : Transactions .ClaimLocalAnchorOutputTx => PublishReplaceableTx (tx, commitments) }
2272
+ val redeemableHtlcTxs = htlcTxs.values.collect { case Some (tx) => PublishReplaceableTx (tx, commitments) }
2273
+ List (PublishRawTx (commitTx, commitInput, " commit-tx" , None )) ++ claimLocalAnchor ++ claimMainDelayedOutputTx.map(tx => PublishRawTx (tx, None )) ++ redeemableHtlcTxs ++ claimHtlcDelayedTxs.map(tx => PublishRawTx (tx, None ))
2274
2274
}
2275
2275
publishIfNeeded(publishQueue, irrevocablySpent)
2276
2276
@@ -2333,7 +2333,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
2333
2333
private def doPublish (remoteCommitPublished : RemoteCommitPublished ): Unit = {
2334
2334
import remoteCommitPublished ._
2335
2335
2336
- val publishQueue = (claimMainOutputTx ++ claimHtlcTxs.values.flatten).map(tx => PublishRawTx (tx))
2336
+ val publishQueue = (claimMainOutputTx ++ claimHtlcTxs.values.flatten).map(tx => PublishRawTx (tx, None ))
2337
2337
publishIfNeeded(publishQueue, irrevocablySpent)
2338
2338
2339
2339
// we watch:
@@ -2372,7 +2372,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
2372
2372
private def doPublish (revokedCommitPublished : RevokedCommitPublished ): Unit = {
2373
2373
import revokedCommitPublished ._
2374
2374
2375
- val publishQueue = (claimMainOutputTx ++ mainPenaltyTx ++ htlcPenaltyTxs ++ claimHtlcDelayedPenaltyTxs).map(tx => PublishRawTx (tx))
2375
+ val publishQueue = (claimMainOutputTx ++ mainPenaltyTx ++ htlcPenaltyTxs ++ claimHtlcDelayedPenaltyTxs).map(tx => PublishRawTx (tx, None ))
2376
2376
publishIfNeeded(publishQueue, irrevocablySpent)
2377
2377
2378
2378
// we watch:
0 commit comments