From ac921759bc4077528e9aa83db7e120b44203f2e1 Mon Sep 17 00:00:00 2001 From: t-bast Date: Wed, 21 Oct 2020 17:31:57 +0200 Subject: [PATCH 1/2] Clarify crossSign helper functions It's important in particular to highlight the case where an HTLC is half-fulfilled or half-failed. --- .../main/scala/fr/acinq/eclair/channel/Commitments.scala | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala index 43cb2d9c60..6e85483b86 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala @@ -106,6 +106,10 @@ case class Commitments(channelVersion: ChannelVersion, remoteNextCommitInfo.left.toSeq.flatMap(_.nextRemoteCommit.spec.htlcs.collect(incoming).filter(expired).toSet) } + /** + * Find an outgoing HTLC that is signed by both parties in at least one of the current commitment transactions (local/remote). + * NB: if we're in the middle of fulfilling or failing that HTLC, it will not be returned by this function. + */ def getOutgoingHtlcCrossSigned(htlcId: Long): Option[UpdateAddHtlc] = for { localSigned <- remoteNextCommitInfo.left.toOption.map(_.nextRemoteCommit).getOrElse(remoteCommit).spec.findIncomingHtlcById(htlcId) remoteSigned <- localCommit.spec.findOutgoingHtlcById(htlcId) @@ -114,6 +118,10 @@ case class Commitments(channelVersion: ChannelVersion, localSigned.add } + /** + * Find an incoming HTLC that is signed by both parties in at least one of the current commitment transactions (local/remote). + * NB: if we're in the middle of fulfilling or failing that HTLC, it will not be returned by this function. + */ def getIncomingHtlcCrossSigned(htlcId: Long): Option[UpdateAddHtlc] = for { localSigned <- remoteNextCommitInfo.left.toOption.map(_.nextRemoteCommit).getOrElse(remoteCommit).spec.findOutgoingHtlcById(htlcId) remoteSigned <- localCommit.spec.findIncomingHtlcById(htlcId) From c4db58c5fcc6659669e122cc6afa9b8cebad6e6c Mon Sep 17 00:00:00 2001 From: t-bast Date: Thu, 22 Oct 2020 10:37:53 +0200 Subject: [PATCH 2/2] fixup! Clarify crossSign helper functions --- .../main/scala/fr/acinq/eclair/channel/Commitments.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala index 6e85483b86..6574aac040 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala @@ -107,7 +107,9 @@ case class Commitments(channelVersion: ChannelVersion, } /** - * Find an outgoing HTLC that is signed by both parties in at least one of the current commitment transactions (local/remote). + * Return the outgoing HTLC with the given id if it is: + * - signed by us in their commitment transaction (remote) + * - signed by them in our commitment transaction (local) * NB: if we're in the middle of fulfilling or failing that HTLC, it will not be returned by this function. */ def getOutgoingHtlcCrossSigned(htlcId: Long): Option[UpdateAddHtlc] = for { @@ -119,7 +121,9 @@ case class Commitments(channelVersion: ChannelVersion, } /** - * Find an incoming HTLC that is signed by both parties in at least one of the current commitment transactions (local/remote). + * Return the incoming HTLC with the given id if it is: + * - signed by us in their commitment transaction (remote) + * - signed by them in our commitment transaction (local) * NB: if we're in the middle of fulfilling or failing that HTLC, it will not be returned by this function. */ def getIncomingHtlcCrossSigned(htlcId: Long): Option[UpdateAddHtlc] = for {