Skip to content

Commit 66977cc

Browse files
authored
Add previous commitments to ChannelFundingConfirmed event (#3303)
Event stream subscribers could use this field to find extra information about previous states that could have been pruned from the current commitments.
1 parent 6bb7f25 commit 66977cc

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

eclair-core/src/main/scala/fr/acinq/eclair/channel/ChannelEvents.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ case class ChannelFundingCreated(channel: ActorRef, channelId: ByteVector32, rem
5858
}
5959

6060
/** This event is sent once a funding transaction (channel creation or splice) has been confirmed. */
61-
case class ChannelFundingConfirmed(channel: ActorRef, channelId: ByteVector32, remoteNodeId: PublicKey, fundingTxId: TxId, fundingTxIndex: Long, blockHeight: BlockHeight, commitments: Commitments) extends ChannelEvent
61+
case class ChannelFundingConfirmed(channel: ActorRef, channelId: ByteVector32, remoteNodeId: PublicKey, fundingTxId: TxId, fundingTxIndex: Long, blockHeight: BlockHeight, commitments: Commitments, previousCommitments: Commitments) extends ChannelEvent
6262

6363
/** This event is sent once channel_ready or splice_locked have been exchanged: the channel is ready to process payments. */
6464
case class ChannelReadyForPayments(channel: ActorRef, remoteNodeId: PublicKey, channelId: ByteVector32, fundingTxId: TxId, fundingTxIndex: Long) extends ChannelEvent

eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/CommonFundingHandlers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ trait CommonFundingHandlers extends CommonHandlers {
103103
val spliceSpendingTxs = commitments1.all.collect { case c if c.fundingTxIndex == commitment.fundingTxIndex + 1 => c.fundingTxId }
104104
watchFundingSpent(commitment, additionalKnownSpendingTxs = spliceSpendingTxs.toSet, None)
105105
// We notify listeners that this funding transaction is now confirmed.
106-
context.system.eventStream.publish(ChannelFundingConfirmed(self, d.channelId, remoteNodeId, w.tx.txid, c.fundingTxIndex, w.blockHeight, commitments1))
106+
context.system.eventStream.publish(ChannelFundingConfirmed(self, d.channelId, remoteNodeId, w.tx.txid, c.fundingTxIndex, w.blockHeight, commitments1, d.commitments))
107107
// We can unwatch the previous funding transaction(s), which have been spent by this splice transaction.
108108
d.commitments.all.collect { case c if c.fundingTxIndex < commitment.fundingTxIndex => blockchain ! UnwatchFundingSpent(c.fundingTxId, c.fundingInput.index.toInt) }
109109
// In the dual-funding/splicing case we can forget all other transactions (RBF attempts), they have been

eclair-node/src/test/scala/fr/acinq/eclair/api/ApiServiceSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
11661166
system.eventStream.publish(chfcr)
11671167
wsClient.expectMessage(expectedSerializedChfcr)
11681168

1169-
val chfc = ChannelFundingConfirmed(system.deadLetters, ByteVector32.One, bobNodeId, fundingTxId, 0, BlockHeight(900000), null)
1169+
val chfc = ChannelFundingConfirmed(system.deadLetters, ByteVector32.One, bobNodeId, fundingTxId, 0, BlockHeight(900000), null, null)
11701170
val expectedSerializedChfc = """{"type":"channel-confirmed","remoteNodeId":"039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a3585","channelId":"0100000000000000000000000000000000000000000000000000000000000000","fundingTxId":"9fcd45bbaa09c60c991ac0425704163c3f3d2d683c789fa409455b9c97792692","fundingTxIndex":0,"blockHeight":900000}"""
11711171
assert(serialization.write(chfc) == expectedSerializedChfc)
11721172
system.eventStream.publish(chfc)

0 commit comments

Comments
 (0)