mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-23 14:40:34 +01:00
do not sent htlcs after you've sent a close_clearing message
This commit is contained in:
parent
5036f8118f
commit
a01b98022a
3 changed files with 19 additions and 1 deletions
|
@ -284,6 +284,10 @@ class Channel(val them: ActorRef, val blockchain: ActorRef, val params: OurChann
|
||||||
*/
|
*/
|
||||||
|
|
||||||
when(NORMAL) {
|
when(NORMAL) {
|
||||||
|
case Event(c:CMD_ADD_HTLC, d: DATA_NORMAL) if d.ourClearing.isDefined =>
|
||||||
|
handleCommandError(sender, new RuntimeException("Cannot sent an update_add_htlc after a close_clearing message"))
|
||||||
|
stay
|
||||||
|
|
||||||
case Event(c@CMD_ADD_HTLC(amount, rHash, expiry, nodeIds, origin, id_opt), d@DATA_NORMAL(commitments, _)) =>
|
case Event(c@CMD_ADD_HTLC(amount, rHash, expiry, nodeIds, origin, id_opt), d@DATA_NORMAL(commitments, _)) =>
|
||||||
Try(Commitments.sendAdd(commitments, c)) match {
|
Try(Commitments.sendAdd(commitments, c)) match {
|
||||||
case Success((commitments1, add)) => handleCommandSuccess(sender, add, d.copy(commitments = commitments1))
|
case Success((commitments1, add)) => handleCommandSuccess(sender, add, d.copy(commitments = commitments1))
|
||||||
|
|
|
@ -41,7 +41,7 @@ case class TheirCommit(index: Long, spec: CommitmentSpec, txid: BinaryData, thei
|
||||||
/**
|
/**
|
||||||
* about theirNextCommitInfo:
|
* about theirNextCommitInfo:
|
||||||
* we either:
|
* we either:
|
||||||
* - have built and sign their next commit tx with their next revocation hash which can now be discarded
|
* - have built and signed their next commit tx with their next revocation hash which can now be discarded
|
||||||
* - have their next revocation hash
|
* - have their next revocation hash
|
||||||
* So, when we've signed and sent a commit message and are waiting for their revocation message,
|
* So, when we've signed and sent a commit message and are waiting for their revocation message,
|
||||||
* theirNextCommitInfo is their next commit tx. The rest of the time, it is their next revocation hash
|
* theirNextCommitInfo is their next commit tx. The rest of the time, it is their next revocation hash
|
||||||
|
|
|
@ -521,6 +521,20 @@ class NormalStateSpec extends TestKit(ActorSystem("test")) with fixture.FunSuite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("do not send htlcs after you've sent a close_clearing message") { case (alice, _, alice2bob, _, alice2blockchain, _) =>
|
||||||
|
within(30 seconds) {
|
||||||
|
val sender = TestProbe()
|
||||||
|
sender.send(alice, CMD_CLOSE(None))
|
||||||
|
alice2bob.expectMsgType[close_clearing]
|
||||||
|
val rand = new Random()
|
||||||
|
val R = rval(rand.nextInt(), rand.nextInt(), rand.nextInt(), rand.nextInt())
|
||||||
|
val H: sha256_hash = Crypto.sha256(R)
|
||||||
|
sender.send(alice, CMD_ADD_HTLC(1000000, H, locktime(Blocks(3))))
|
||||||
|
alice2bob.expectNoMsg(500 milliseconds)
|
||||||
|
awaitCond(alice.stateName == NORMAL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ignore("recv close_clearing (with unacked received htlcs)") { case (alice, bob, alice2bob, bob2alice, alice2blockchain, _) =>
|
ignore("recv close_clearing (with unacked received htlcs)") { case (alice, bob, alice2bob, bob2alice, alice2blockchain, _) =>
|
||||||
within(30 seconds) {
|
within(30 seconds) {
|
||||||
val sender = TestProbe()
|
val sender = TestProbe()
|
||||||
|
|
Loading…
Add table
Reference in a new issue