1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-24 14:50:46 +01:00

Clarify crossSign helper functions (#1578)

It's important in particular to highlight the case where an HTLC is
half-fulfilled or half-failed.
This commit is contained in:
Bastien Teinturier 2020-10-22 11:20:08 +02:00 committed by GitHub
parent 98508f3041
commit e74f345817
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,6 +106,12 @@ case class Commitments(channelVersion: ChannelVersion,
remoteNextCommitInfo.left.toSeq.flatMap(_.nextRemoteCommit.spec.htlcs.collect(incoming).filter(expired).toSet)
}
/**
* 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 {
localSigned <- remoteNextCommitInfo.left.toOption.map(_.nextRemoteCommit).getOrElse(remoteCommit).spec.findIncomingHtlcById(htlcId)
remoteSigned <- localCommit.spec.findOutgoingHtlcById(htlcId)
@ -114,6 +120,12 @@ case class Commitments(channelVersion: ChannelVersion,
localSigned.add
}
/**
* 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 {
localSigned <- remoteNextCommitInfo.left.toOption.map(_.nextRemoteCommit).getOrElse(remoteCommit).spec.findOutgoingHtlcById(htlcId)
remoteSigned <- localCommit.spec.findIncomingHtlcById(htlcId)