Force-close again when a splice RBF sibling confirms (#3400)
What changed, and why it matters
This commit fixes a bug in Eclair, a Bitcoin Lightning Network node implementation. When one node force-closed a channel because its peer never finished signing a 'splice' (a way to resize a Lightning channel on-chain), and the peer later published a different version of that splice (an RBF attempt) which confirmed, Eclair failed to notice that the confirmed transaction had replaced the one used in the force-close. As a result, the node would not re-force-close with the correct commitment, leaving its funds stuck and its payment guarantees unenforced on-chain. The fix makes Eclair re-force-close whenever the confirmed splice transaction spends the same funds as the previously published commitment.
Apply the patch and run the new regression test. Operators should upgrade to a release containing this fix to avoid stuck funds and unenforced HTLCs when peers delay tx_signatures for splice RBF attempts.
Security signals we found
Funds-locking bug in channel close logic
HTLCs not enforced on-chain after confirmed double-spend
Incorrect re-force-close trigger condition
RBF sibling splice not detected as double-spend
Regression test added for unsigned splice RBF force-close scenario
Evidence from the diff
In Channel.scala, the condition that decides whether to re-force-close after a splice confirms was too narrow. It previously checked whether the published local commitment’s funding transaction had a strictly lower fundingTxIndex than the confirmed splice. This missed the case where the confirmed transaction was an RBF sibling of the same splice: same fundingTxIndex, different fundingTxId, double-spending the commitment tx already on chain. The patch changes the condition to trigger when the confirmed splice’s fundingTxId differs from the commitment’s fundingTxId and its fundingTxIndex is greater than or equal, ensuring RBF siblings are detected. A regression test simulates Alice RBFing a splice, Bob force-closing with the pre-RBF commitment, then the RBF tx confirming, and verifies Bob re-force-closes using the RBF commitment.
Changed components
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scalaeclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalSplicesStateSpec.scalaInspect captured patch +59 / −7
### eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
@@ -2198,12 +2198,12 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
)
val d1 = d.copy(commitments = commitments2)
spendLocalCurrent(d1, d.maxClosingFeerate_opt)
- } else if (d.localCommitPublished.exists(lcp => d.commitments.resolveCommitment(lcp.commitTx).exists(_.fundingTxIndex < commitment.fundingTxIndex))) {
- // We force-closed using a previous commitment, because our peer hadn't sent their tx_signatures for this
- // splice transaction and we couldn't publish it. They have now published it and it confirmed, which
- // double-spends the commit tx we published: we must force-close again using the commitment that spends
- // this splice transaction.
- log.warning("splice fundingTxIndex={} fundingTxId={} confirmed after we force-closed using a previous commitment", commitment.fundingTxIndex, commitment.fundingTxId)
+ } else if (d.localCommitPublished.exists(lcp => d.commitments.resolveCommitment(lcp.commitTx).exists(c => c.fundingTxId != commitment.fundingTxId && c.fundingTxIndex <= commitment.fundingTxIndex))) {
+ // We force-closed using a previous commitment or an RBF sibling of this splice transaction, because our
+ // peer hadn't sent their tx_signatures for it and we couldn't publish it. They have now published it and
+ // it confirmed, which double-spends the commit tx we published: we must force-close again using the
+ // commitment that spends this splice transaction.
+ log.warning("splice fundingTxIndex={} fundingTxId={} confirmed after we force-closed using a commitment that it double-spends", commitment.fundingTxIndex, commitment.fundingTxId)
spendLocalCurrent(d.copy(commitments = commitments1), d.maxClosingFeerate_opt)
} else {
// We're still on the same splice history, nothing to do
### eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalSplicesStateSpec.scala
@@ -32,7 +32,7 @@ import fr.acinq.eclair.channel._
import fr.acinq.eclair.channel.fsm.Channel
import fr.acinq.eclair.channel.fund.InteractiveTxBuilder.FullySignedSharedTransaction
import fr.acinq.eclair.channel.fund.InteractiveTxSigningSession
-import fr.acinq.eclair.channel.publish.TxPublisher.SetChannelId
+import fr.acinq.eclair.channel.publish.TxPublisher.{PublishFinalTx, SetChannelId}
import fr.acinq.eclair.channel.states.ChannelStateTestsBase.{FakeTxPublisherFactory, PimpTestFSM}
import fr.acinq.eclair.channel.states.{ChannelStateTestsBase, ChannelStateTestsTags}
import fr.acinq.eclair.crypto.keymanager.RemoteCommitmentKeys
@@ -3951,6 +3951,58 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
assert(bob.stateData.asInstanceOf[DATA_CLOSING].commitmentFor(commitTx2.txid).fundingTxId == spliceTx.txid)
}
+ test("force-close with unsigned splice RBF attempt (tx_signatures not received)") { f =>
+ import f._
+
+ val htlcs = setupHtlcs(f)
+ val spliceTx = initiateSplice(f, spliceIn_opt = Some(SpliceIn(500_000 sat)), spliceOut_opt = Some(SpliceOut(100_000 sat, defaultSpliceOutScriptPubKey)))
+ assert(alice2blockchain.expectMsgType[WatchFundingConfirmed].txId == spliceTx.txid)
+ bob2blockchain.expectWatchFundingConfirmed(spliceTx.txid)
+ val spliceTxIndex = bob.commitments.latest.fundingTxIndex
+
+ // Alice RBFs the splice transaction: Bob doesn't contribute any input, so he must send his tx_signatures first.
+ val sender = initiateRbfWithoutSigs(f, FeeratePerKw(15_000 sat), sInputsCount = 2, sOutputsCount = 2)
+ alice2bob.expectMsgType[CommitSig]
+ alice2bob.forward(bob)
+ bob2alice.expectMsgType[CommitSig]
+ bob2alice.forward(alice)
+ val bobSigs = bob2alice.expectMsgType[TxSignatures] // Alice doesn't receive Bob's tx_signatures
+ bob2blockchain.expectWatchFundingConfirmed(bobSigs.txId)
+ awaitCond(bob.stateData.asInstanceOf[DATA_NORMAL].spliceStatus == SpliceStatus.NoSplice)
+ val rbfCommitment = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.latest
+ assert(rbfCommitment.fundingTxIndex == spliceTxIndex)
+ assert(rbfCommitment.fundingTxId == bobSigs.txId)
+ assert(rbfCommitment.localFundingStatus.signedTx_opt.isEmpty)
+
+ // Bob cannot publish the RBF transaction, so he force-closes using the commitment of the previous splice attempt.
+ bob ! CMD_FORCECLOSE(ActorRef.noSender)
+ bob2alice.expectMsgType[Error]
+ val commitTx1 = bob2blockchain.expectFinalTxPublished("commit-tx").tx
+ assert(commitTx1.txIn.map(_.outPoint.txid) == Seq(spliceTx.txid))
+ bob2blockchain.expectReplaceableTxPublished[ClaimLocalAnchorTx]
+ bob2blockchain.expectFinalTxPublished("local-main-delayed")
+ htlcs.bobToAlice.foreach(_ => bob2blockchain.expectReplaceableTxPublished[HtlcTimeoutTx])
+ bob2blockchain.expectWatchTxConfirmed(commitTx1.txid)
+ val lcp1 = bob.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get
+ bob2blockchain.expectWatchOutputsSpent(lcp1.localOutput_opt.toSeq ++ lcp1.anchorOutput_opt.toSeq ++ lcp1.htlcOutputs.toSeq)
+
+ // Alice receives Bob's tx_signatures and publishes the RBF transaction, which confirms.
+ bob2alice.forward(alice, bobSigs)
+ alice2bob.expectMsgType[TxSignatures]
+ sender.expectMsgType[RES_SPLICE]
+ val rbfTx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.latest.localFundingStatus.signedTx_opt.get
+ assert(rbfTx.txid == rbfCommitment.fundingTxId)
+ bob ! WatchFundingConfirmedTriggered(BlockHeight(400000), 42, rbfTx)
+ // Bob's previous commit tx has been double-spent by the RBF transaction: he force-closes using the RBF commitment.
+ val commitTx2 = bob2blockchain.fishForMessage() {
+ case p: PublishFinalTx => p.desc == "commit-tx"
+ case _ => false
+ }.asInstanceOf[PublishFinalTx].tx
+ Transaction.correctlySpends(commitTx2, Seq(rbfTx), ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS)
+ assert(bob.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.map(_.commitTx.txid).contains(commitTx2.txid))
+ assert(bob.stateData.asInstanceOf[DATA_CLOSING].commitmentFor(commitTx2.txid).fundingTxId == rbfTx.txid)
+ }
+
test("force-close with multiple splices (previous active remote)", Tag(ChannelStateTestsTags.OptionSimpleTaproot), Tag(ChannelStateTestsTags.ZeroConf)) { f =>
import f._
Why this scored 66/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.