Skip to content

Commit

Permalink
Fix splice reconnection while signing (#2673)
Browse files Browse the repository at this point in the history
And add tests for splice disconnection/reconnection scenarios.
  • Loading branch information
t-bast authored May 25, 2023
1 parent 41b8d5c commit 84f1d03
Show file tree
Hide file tree
Showing 2 changed files with 405 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import akka.actor.typed.scaladsl.adapter.{ClassicActorContextOps, actorRefAdapte
import akka.actor.{Actor, ActorContext, ActorRef, FSM, OneForOneStrategy, PossiblyHarmful, Props, SupervisorStrategy, typed}
import akka.event.Logging.MDC
import fr.acinq.bitcoin.scalacompat.Crypto.{PrivateKey, PublicKey}
import fr.acinq.bitcoin.scalacompat.{Block, ByteVector32, Satoshi, SatoshiLong, Transaction}
import fr.acinq.bitcoin.scalacompat.{ByteVector32, Satoshi, SatoshiLong, Transaction}
import fr.acinq.eclair.Features.SplicePrototype
import fr.acinq.eclair.Logs.LogCategory
import fr.acinq.eclair._
Expand Down Expand Up @@ -835,7 +835,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
stay() using d.copy(spliceStatus = SpliceStatus.SpliceAborted) sending TxAbort(d.channelId, InvalidSpliceRequest(d.channelId).getMessage)
} else {
log.info(s"accepting splice with remote.in.amount=${msg.fundingContribution} remote.in.push=${msg.pushAmount}")
val parentCommitment = d.commitments.latest.commitment
val parentCommitment = d.commitments.latest.commitment
val spliceAck = SpliceAck(d.channelId,
fundingContribution = 0.sat, // only remote contributes to the splice
fundingPubKey = keyManager.fundingPublicKey(d.commitments.params.localParams.fundingKeyPath, parentCommitment.fundingTxIndex + 1).publicKey,
Expand Down Expand Up @@ -1684,6 +1684,13 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
case _: InteractiveTxBuilder.FullySignedSharedTransaction => TlvStream.empty
}
}
case d: DATA_NORMAL => d.spliceStatus match {
case SpliceStatus.SpliceWaitingForSigs(status) => TlvStream(ChannelReestablishTlv.NextFundingTlv(status.fundingTx.txId.reverse))
case _ => d.commitments.latest.localFundingStatus match {
case LocalFundingStatus.DualFundedUnconfirmedFundingTx(fundingTx: PartiallySignedSharedTransaction, _, _) => TlvStream(ChannelReestablishTlv.NextFundingTlv(fundingTx.txId.reverse))
case _ => TlvStream.empty
}
}
case _ => TlvStream.empty
}
val channelReestablish = ChannelReestablish(
Expand Down
Loading

0 comments on commit 84f1d03

Please sign in to comment.