]> git.bitcoin.ninja Git - rust-lightning/commit
Don't fail HTLCs in revoked commitment txn until we spend them 2022-05-revoked-txn-edge-cases
authorMatt Corallo <git@bluematt.me>
Sat, 30 Apr 2022 20:30:00 +0000 (20:30 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 21 Jun 2022 16:14:55 +0000 (16:14 +0000)
commit70ae45fea030ed1d2064918c7b023aa142387bc8
tree3c143b4dfafce5143d407097d35d5dea8af26ac8
parent44d1dfa23dcb19be6f3a02f7e18b3b905c1d4683
Don't fail HTLCs in revoked commitment txn until we spend them

When we see a counterparty revoked commitment transaction on-chain
we shouldn't immediately queue up HTLCs present in it for
resolution until we have spent the HTLC outputs in some kind of
claim transaction.

In order to do so, we first have to change the
`fail_unbroadcast_htlcs!()` call to provide it with the HTLCs which
are present in the (revoked) commitment transaction which was
broadcast. However, this is not sufficient - because all of those
HTLCs had their `HTLCSource` removed when the commitment
transaction was revoked, we also have to update
`fail_unbroadcast_htlcs` to check the payment hash and amount when
the `HTLCSource` is `None`.

Somewhat surprisingly, several tests actually explicitly tested for
the old behavior, which required amending to pass with the new
changes.

Finally, this adds a debug assertion when writing `ChannelMonitor`s
to ensure `HTLCSource`s do not leak.
lightning/src/chain/channelmonitor.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/monitor_tests.rs