Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eclair-core/src/main/scala/fr/acinq/eclair/io/Peer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class Peer(val nodeParams: NodeParams,
stay() using d.copy(channels = d.channels + (TemporaryChannelId(temporaryChannelId) -> channel))

case Event(open: protocol.OpenChannel, d: ConnectedData) =>
d.channels.get(TemporaryChannelId(open.temporaryChannelId)) match {
d.channels.get(TemporaryChannelId(open.temporaryChannelId)).orElse(d.channels.get(FinalChannelId(open.temporaryChannelId))) match {
case None =>
openChannelInterceptor ! OpenChannelNonInitiator(remoteNodeId, Left(open), d.localFeatures, d.remoteFeatures, d.peerConnection.toTyped, d.address)
stay()
Expand All @@ -249,7 +249,7 @@ class Peer(val nodeParams: NodeParams,
}

case Event(open: protocol.OpenDualFundedChannel, d: ConnectedData) =>
d.channels.get(TemporaryChannelId(open.temporaryChannelId)) match {
d.channels.get(TemporaryChannelId(open.temporaryChannelId)).orElse(d.channels.get(FinalChannelId(open.temporaryChannelId))) match {
case None if !Features.canUseFeature(d.localFeatures, d.remoteFeatures, Features.DualFunding) =>
log.info("rejecting open_channel2: dual funding is not supported")
self ! Peer.OutgoingMessage(Error(open.temporaryChannelId, "dual funding is not supported"), d.peerConnection)
Expand Down
17 changes: 17 additions & 0 deletions eclair-core/src/test/scala/fr/acinq/eclair/io/PeerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,23 @@ class PeerSpec extends FixtureSpec {
assert(peer.stateData.channels.size == 1)
}

test("don't spawn a channel that reuses an existing channel id") { f =>
import f._

val confirmedChannel = ChannelCodecsSpec.normal.withChannelKeys(nodeParams)
connect(remoteNodeId, peer, peerConnection, switchboard, channels = Set(confirmedChannel))
channel.expectMsg(INPUT_RESTORED(confirmedChannel.channelData))
channel.expectMsgType[INPUT_RECONNECTED]

val open = createOpenChannelMessage(ChannelTypes.AnchorOutputsZeroFeeHtlcTx()).copy(temporaryChannelId = confirmedChannel.channelId)
peerConnection.send(peer, open)
val open2 = createOpenDualFundedChannelMessage(ChannelTypes.AnchorOutputsZeroFeeHtlcTx()).copy(temporaryChannelId = confirmedChannel.channelId)
peerConnection.send(peer, open2)
channel.expectNoMessage(100 millis)
peerConnection.expectNoMessage(100 millis)
assert(peer.stateData.channels.size == 1)
}

test("send error when receiving message for unknown channel") { f =>
import f._

Expand Down
Loading