From f9fe2289cf58b639ef80951cb0eee34cac990058 Mon Sep 17 00:00:00 2001 From: sstone Date: Mon, 22 Jul 2024 11:49:49 +0200 Subject: [PATCH] Fixup: Simplify DATA_WAIT_FOR_DUAL_FUNDING_CREATED and DATA_WAIT_FOR_DUAL_FUNDING_SIGNED --- .../fr/acinq/eclair/channel/ChannelData.scala | 4 +--- .../eclair/channel/fsm/ChannelOpenDualFunded.scala | 6 +++--- .../internal/channel/version4/ChannelCodecs4.scala | 14 +------------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/ChannelData.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/ChannelData.scala index 2f22a8e647..dfcf81083f 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/ChannelData.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/ChannelData.scala @@ -575,15 +575,13 @@ final case class DATA_WAIT_FOR_DUAL_FUNDING_CREATED(channelId: ByteVector32, remotePushAmount: MilliSatoshi, txBuilder: typed.ActorRef[InteractiveTxBuilder.Command], deferred: Option[CommitSig], - secondRemoteNonce_opt: Option[IndividualNonce], replyTo_opt: Option[akka.actor.typed.ActorRef[Peer.OpenChannelResponse]]) extends TransientChannelData final case class DATA_WAIT_FOR_DUAL_FUNDING_SIGNED(channelParams: ChannelParams, secondRemotePerCommitmentPoint: PublicKey, localPushAmount: MilliSatoshi, remotePushAmount: MilliSatoshi, signingSession: InteractiveTxSigningSession.WaitingForSigs, - remoteChannelData_opt: Option[ByteVector], - secondRemoteNonce_opt: Option[IndividualNonce]) extends ChannelDataWithoutCommitments + remoteChannelData_opt: Option[ByteVector]) extends ChannelDataWithoutCommitments final case class DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED(commitments: Commitments, localPushAmount: MilliSatoshi, remotePushAmount: MilliSatoshi, diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/ChannelOpenDualFunded.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/ChannelOpenDualFunded.scala index 8ddb4f0c7a..d6e51f9087 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/ChannelOpenDualFunded.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/ChannelOpenDualFunded.scala @@ -237,7 +237,7 @@ trait ChannelOpenDualFunded extends DualFundingHandlers with ErrorHandlers { open.firstRemoteNonce)) txBuilder ! InteractiveTxBuilder.Start(self) setRemoteNextLocalNonces("received OpenDualFundedChannel", open.secondRemoteNonce.toList) - goto(WAIT_FOR_DUAL_FUNDING_CREATED) using DATA_WAIT_FOR_DUAL_FUNDING_CREATED(channelId, channelParams, open.secondPerCommitmentPoint, accept.pushAmount, open.pushAmount, txBuilder, deferred = None, open.secondRemoteNonce, replyTo_opt = None) sending accept + goto(WAIT_FOR_DUAL_FUNDING_CREATED) using DATA_WAIT_FOR_DUAL_FUNDING_CREATED(channelId, channelParams, open.secondPerCommitmentPoint, accept.pushAmount, open.pushAmount, txBuilder, deferred = None, replyTo_opt = None) sending accept } case Event(c: CloseCommand, d) => handleFastClose(c, d.channelId) @@ -302,7 +302,7 @@ trait ChannelOpenDualFunded extends DualFundingHandlers with ErrorHandlers { accept.firstRemoteNonce)) txBuilder ! InteractiveTxBuilder.Start(self) setRemoteNextLocalNonces("received AcceptDualFundedChannel", accept.secondRemoteNonce.toList) - goto(WAIT_FOR_DUAL_FUNDING_CREATED) using DATA_WAIT_FOR_DUAL_FUNDING_CREATED(channelId, channelParams, accept.secondPerCommitmentPoint, d.lastSent.pushAmount, accept.pushAmount, txBuilder, deferred = None, accept.secondRemoteNonce, replyTo_opt = Some(d.init.replyTo)) + goto(WAIT_FOR_DUAL_FUNDING_CREATED) using DATA_WAIT_FOR_DUAL_FUNDING_CREATED(channelId, channelParams, accept.secondPerCommitmentPoint, d.lastSent.pushAmount, accept.pushAmount, txBuilder, deferred = None, replyTo_opt = Some(d.init.replyTo)) } case Event(c: CloseCommand, d: DATA_WAIT_FOR_ACCEPT_DUAL_FUNDED_CHANNEL) => @@ -355,7 +355,7 @@ trait ChannelOpenDualFunded extends DualFundingHandlers with ErrorHandlers { case InteractiveTxBuilder.Succeeded(status, commitSig) => d.deferred.foreach(self ! _) d.replyTo_opt.foreach(_ ! OpenChannelResponse.Created(d.channelId, status.fundingTx.txId, status.fundingTx.tx.localFees.truncateToSatoshi)) - val d1 = DATA_WAIT_FOR_DUAL_FUNDING_SIGNED(d.channelParams, d.secondRemotePerCommitmentPoint, d.localPushAmount, d.remotePushAmount, status, None, d.secondRemoteNonce_opt) + val d1 = DATA_WAIT_FOR_DUAL_FUNDING_SIGNED(d.channelParams, d.secondRemotePerCommitmentPoint, d.localPushAmount, d.remotePushAmount, status, None) goto(WAIT_FOR_DUAL_FUNDING_SIGNED) using d1 storing() sending commitSig case f: InteractiveTxBuilder.Failed => d.replyTo_opt.foreach(_ ! OpenChannelResponse.Rejected(f.cause.getMessage)) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/wire/internal/channel/version4/ChannelCodecs4.scala b/eclair-core/src/main/scala/fr/acinq/eclair/wire/internal/channel/version4/ChannelCodecs4.scala index 01fd4260aa..34a9094d3a 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/wire/internal/channel/version4/ChannelCodecs4.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/wire/internal/channel/version4/ChannelCodecs4.scala @@ -1,7 +1,6 @@ package fr.acinq.eclair.wire.internal.channel.version4 import fr.acinq.bitcoin.ScriptTree -import fr.acinq.bitcoin.crypto.musig2.IndividualNonce import fr.acinq.bitcoin.scalacompat.Crypto.PublicKey import fr.acinq.bitcoin.scalacompat.DeterministicWallet.KeyPath import fr.acinq.bitcoin.scalacompat.{ByteVector64, OutPoint, ScriptWitness, Transaction, TxOut} @@ -670,15 +669,6 @@ private[channel] object ChannelCodecs4 { val DATA_WAIT_FOR_CHANNEL_READY_0b_Codec: Codec[DATA_WAIT_FOR_CHANNEL_READY] = ( ("commitments" | versionedCommitmentsCodec) :: ("shortIds" | shortids)).as[DATA_WAIT_FOR_CHANNEL_READY] - - val DATA_WAIT_FOR_DUAL_FUNDING_SIGNED_13_Codec: Codec[DATA_WAIT_FOR_DUAL_FUNDING_SIGNED] = ( - ("channelParams" | paramsCodec) :: - ("secondRemotePerCommitmentPoint" | publicKey) :: - ("localPushAmount" | millisatoshi) :: - ("remotePushAmount" | millisatoshi) :: - ("status" | interactiveTxWaitingForSigsCodec) :: - ("remoteChannelData_opt" | optional(bool8, varsizebinarydata)) :: - ("secondRemoteNonce_opt" | optional(bool8, publicNonce))).as[DATA_WAIT_FOR_DUAL_FUNDING_SIGNED] val DATA_WAIT_FOR_DUAL_FUNDING_SIGNED_09_Codec: Codec[DATA_WAIT_FOR_DUAL_FUNDING_SIGNED] = ( ("channelParams" | paramsCodec) :: @@ -686,8 +676,7 @@ private[channel] object ChannelCodecs4 { ("localPushAmount" | millisatoshi) :: ("remotePushAmount" | millisatoshi) :: ("status" | interactiveTxWaitingForSigsCodec) :: - ("remoteChannelData_opt" | optional(bool8, varsizebinarydata)) :: - ("secondRemoteNonce_opt" | provide[Option[IndividualNonce]](None))).as[DATA_WAIT_FOR_DUAL_FUNDING_SIGNED] + ("remoteChannelData_opt" | optional(bool8, varsizebinarydata))).as[DATA_WAIT_FOR_DUAL_FUNDING_SIGNED] val DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED_02_Codec: Codec[DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED] = ( ("commitments" | commitmentsCodecWithoutFirstRemoteCommitIndex) :: @@ -796,7 +785,6 @@ private[channel] object ChannelCodecs4 { // Order matters! val channelDataCodec: Codec[PersistentChannelData] = discriminated[PersistentChannelData].by(uint16) - .typecase(0x13, Codecs.DATA_WAIT_FOR_DUAL_FUNDING_SIGNED_13_Codec) .typecase(0x12, Codecs.DATA_WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT_12_Codec) .typecase(0x11, Codecs.DATA_CLOSING_11_Codec) .typecase(0x10, Codecs.DATA_NEGOTIATING_10_Codec)