this is handled differently in lightning, see commit
commit 6e355601261a60d143561f15760cc48f9c81d000
Author: ThomasV <thomasv@electrum.org>
Date: Sun Jun 3 10:07:56 2018 +0200
integrate channels_list with existing framework
in the case where an htlc is failed, it could happen
that we use the wrong list of htlcs to generate sweep
tx'es. we would use the pending list instead of the
committed list.
observed by sending 12300sat and then 123000sat,
the second payment fails and an AssertionError was
triggered cause the htlc output could not be found
in the ctx.
added some documentation to clarify the behaviour
of lnchan.included_htlcs.
pycryptodomex 3.7 implemented chacha20_poly1305 and chacha20,
and it is already used (although optionally) to speed up AES,
so we can remove cryptography and make pycryptodomex mandatory for LN
- add 'CLOSING' state
- wait until channel has no inflight HTLC
- end fee negocitation when both parties agree on the fee
(previously code ended it only when the other party had broadcast)
- broadcast the closing transaction
this workaround was inserted to avoid losing the interface
when rebroadcasting a transaction already in the mempool
many times. but since the network should make sure we always
have a interface ready, and this problem shouldn't happen on
mainnet, remove the workaround
previously, we would try to publish the second_stage
even if we couldn't, because a conflicting transaction
was published (like an htlc success when we close with
htlcs pending with a 1-hop payment and an online
counterparty)