Do not generate a channel-closed mon update for never-signed chans
authorMatt Corallo <git@bluematt.me>
Sun, 15 Nov 2020 21:44:09 +0000 (16:44 -0500)
committerMatt Corallo <git@bluematt.me>
Mon, 23 Nov 2020 22:00:07 +0000 (17:00 -0500)
commit22de94afdde4ee6f960eedff3d6a7d01a76445ff
tree45fbc4e3101a3f255bbe89aebd00018c0d890839
parent8f10a1d33d8c4ec38cc39c9e013da24386e13f85
Do not generate a channel-closed mon update for never-signed chans

The full_stack_target managed to find a bug where, if we receive
a funding_created message which has a channel_id identical to an
existing channel, we'll end up
 (a) having the monitor update for the new channel fail (due to
     duplicate outpoint),
 (b) creating a monitor update for the new channel as we
     force-close it,
 (c) panicing due to the force-close monitor update is applied to
     the original channel and is considered out-of-order.

Obviously we shouldn't be creating a force-close monitor update for
a channel which can never appear on chain, so we do that here and
add a test which previously failed and checks a few
duplicate-channel-id cases.
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs