Description
Hi,
I think there is something wrong with how unacked htlcs are handled by lightning-c during mutual closing. The spec is a little vague on this so I can't tell if lightning-c implementation does or doesn't comply. I guess it depends on how one side indicating that it wants to clear the channel (and thus will accept no new HTLCs)
(bolt02, §4) is interpreted.
In file peer.c (lines 402 and 434), we go to STATE_MUTUAL_CLOSING when there are no htlcs in signed tx (actual check is done in function committed_to_htlcs
).
But I don't see why we shouldn't keep the unacked htlcs. As soon as both parties have sent and received a close_clearing
packet, and because they agree not to send any new htlcs after having sent their own close_clearing
packet (bolt02, §4.1), the state is perfectly well-defined and all pending htlcs (sent & received) could be included.
What bothers me is that in the rest of the protocol we assume that a valid htlc will always be accepted (there is no way for a peer to say 'no'), so the fact that in this specific case some htlcs could be discarded doesn't seem very consistent.
What do you think?
Cheers,
Pierre