Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify crossSign helper functions #1578

Merged
merged 2 commits into from
Oct 22, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down