Fix to_remote SpendableOutputs generation in rare reorg cases 2021-07-to-remote-reorg
authorMatt Corallo <git@bluematt.me>
Thu, 29 Jul 2021 19:49:09 +0000 (19:49 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 4 Aug 2021 02:34:57 +0000 (02:34 +0000)
commitad4459080e823d4e61de92add5f8b2748dcdc88c
tree9cb707a7c2f2373d368c92ee2d721ca13f7fb46e
parente26c9b051a5983eae1f38fbd403763ad9924bf13
Fix to_remote SpendableOutputs generation in rare reorg cases

If we first see a local commitment transaction, and then a reorg
causes the confirmed channel close transaction to instead be a
remote commitment transaction, we would fail a spurious `if else`
check, resulting in us not generating the correct `SpendableOutput`
event for the to_remote output now confirmed on chain.

This resolves the incorrect logic and adds a regression test.
lightning/src/chain/channelmonitor.rs
lightning/src/ln/reorg_tests.rs