Allow claiming a payment if a channel with an HTLC has closed
authorMatt Corallo <git@bluematt.me>
Tue, 4 Apr 2023 04:12:55 +0000 (04:12 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 4 Apr 2023 23:08:46 +0000 (23:08 +0000)
commitab255895eed9c4d9ed2dc400d7e0c720ea763ba8
tree915926f73a58bde3d3c46e7b7257884c27f797e7
parent3b8bf93251a9c8aa528c6961d572a611bc140eb5
Allow claiming a payment if a channel with an HTLC has closed

Previously, LDK would refuse to claim a payment if a channel on
which the payment was received had been closed between when the
HTLC was received and when we went to claim it. This makes sense in
the payment case - why pay an on-chain fee to claim the HTLC when
presumably the sender may retry later. Long ago it also reduced
total code in the claim pipeline.

However, this doesn't make sense if you're trying to do an atomic
swap or some other protocol that requires atomicity with some other
action - if your money got claimed elsewhere you need to be able to
claim the HTLC in lightning no matter what. Further, this is an
over-optimization - there should be a very, very low likelihood
that a channel closes between when we receive the last HTLC for a
payment and the user goes to claim the payment. Since we now have
code to handle this anyway we should allow it.

Fixes #2017.
lightning/src/ln/channelmanager.rs
lightning/src/ln/payment_tests.rs