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

graceful handling of unknown r

This commit is contained in:
pm47 2016-02-17 11:25:19 +01:00
parent 9a55c24c85
commit 82fe428b99

View file

@ -501,13 +501,18 @@ class Channel(val blockchain: ActorRef, val params: OurChannelParams) extends Lo
them ! update_accept(ourSigForThem, ourRevocationHash)
goto(WAIT_FOR_UPDATE_SIG(priority)) using DATA_WAIT_FOR_UPDATE_SIG(ourParams, theirParams, shaChain, commitment, Commitment(commitment.index + 1, newCommitmentTx, newState, theirRevocationHash))
case Event(CMD_SEND_HTLC_FULFILL(r), DATA_NORMAL(ourParams, theirParams, shaChain, commitment@Commitment(_, _, previousState, _))) =>
case Event(c@CMD_SEND_HTLC_FULFILL(r), DATA_NORMAL(ourParams, theirParams, shaChain, commitment@Commitment(_, _, previousState, _))) =>
// we paid upstream in exchange for r, now lets gets paid
val newState = previousState.htlc_fulfill(r)
val ourRevocationHash = Crypto.sha256(ShaChain.shaChainFromSeed(ourParams.shaSeed, commitment.index + 1))
// Complete your HTLC: I have the R value, pay me!
them ! update_fulfill_htlc(ourRevocationHash, r)
goto(WAIT_FOR_HTLC_ACCEPT(priority)) using DATA_WAIT_FOR_HTLC_ACCEPT(ourParams, theirParams, shaChain, commitment, UpdateProposal(commitment.index + 1, newState))
Try(previousState.htlc_fulfill(r)) match {
case Success(newState) =>
val ourRevocationHash = Crypto.sha256(ShaChain.shaChainFromSeed(ourParams.shaSeed, commitment.index + 1))
// Complete your HTLC: I have the R value, pay me!
them ! update_fulfill_htlc(ourRevocationHash, r)
goto(WAIT_FOR_HTLC_ACCEPT(priority)) using DATA_WAIT_FOR_HTLC_ACCEPT(ourParams, theirParams, shaChain, commitment, UpdateProposal(commitment.index + 1, newState))
case Failure(t) =>
log.error(t, s"command $c failed")
stay
}
case Event(update_fulfill_htlc(theirRevocationHash, r), DATA_NORMAL(ourParams, theirParams, shaChain, commitment)) =>
val newState = commitment.state.htlc_fulfill(r)