Browse Source
ln: don't break channel when failing htlc
regtest_lnd
Janus
7 years ago
committed by
SomberNight
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
2 changed files with
7 additions and
6 deletions
-
lib/lnbase.py
-
lib/tests/test_lnhtlc.py
|
|
@ -1153,17 +1153,17 @@ class Peer(PrintError): |
|
|
|
|
|
|
|
done, pending = await asyncio.wait([fulfill_coro, failure_coro], return_when=FIRST_COMPLETED) |
|
|
|
if failure_coro.done(): |
|
|
|
sig_64, htlc_sigs = m.sign_next_commitment() |
|
|
|
self.send_message(gen_msg("commitment_signed", channel_id=chan.channel_id, signature=sig_64, num_htlcs=1, htlc_signature=htlc_sigs[0])) |
|
|
|
while (await self.commitment_signed[chan.channel_id].get())["htlc_signature"] != b"": |
|
|
|
self.revoke(m) |
|
|
|
await self.receive_revoke(m) |
|
|
|
m.fail_htlc(htlc) |
|
|
|
# TODO receive their commitment here |
|
|
|
|
|
|
|
# TODO find out why the following block fails with "not enough htlc signatures" |
|
|
|
sig_64, htlc_sigs = m.sign_next_commitment() |
|
|
|
assert len(htlc_sigs) == 0 |
|
|
|
self.send_message(gen_msg("commitment_signed", channel_id=chan.channel_id, signature=sig_64, num_htlcs=0)) |
|
|
|
|
|
|
|
await self.receive_revoke(m) |
|
|
|
self.revoke(m) |
|
|
|
fulfill_coro.cancel() |
|
|
|
self.lnworker.save_channel(m.state) |
|
|
|
return failure_coro.result() |
|
|
|
if fulfill_coro.done(): |
|
|
|
failure_coro.cancel() |
|
|
|
|
|
@ -202,6 +202,7 @@ class TestLNBaseHTLCStateMachine(unittest.TestCase): |
|
|
|
|
|
|
|
aliceRevocation2, _ = alice_channel.revoke_current_commitment() |
|
|
|
aliceSig2, aliceHtlcSigs2 = alice_channel.sign_next_commitment() |
|
|
|
self.assertEqual(aliceHtlcSigs2, [], "alice should generate no htlc signatures") |
|
|
|
|
|
|
|
bob_channel.receive_revocation(aliceRevocation2) |
|
|
|
|
|
|
|