Fix spurious panic on receipt of a block while awaiting funding 2022-08-0conf-panic
authorMatt Corallo <git@bluematt.me>
Mon, 29 Aug 2022 18:42:34 +0000 (18:42 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 9 Sep 2022 17:19:21 +0000 (17:19 +0000)
commitcb1db613008ea6845f3c11b1f3ad594b4dc24623
tree2de674cc98804da3dccad8b7ae6c6618993cca2c
parent4905df889498ec520932ea6684b0ffabbd226641
Fix spurious panic on receipt of a block while awaiting funding

When we receive a block we always test if we should send our
channel_ready via `check_get_channel_ready`. If the channel in
question requires confirmations, we quickly return if the funding
transaction has not yet confirmed (or even been defined), however
for 0conf channels the checks are necessarily more involved.

In any case, we wish to panic if the funding transaction has
confirmations prior to when it should have been broadcasted. This
is useful as it is easy for users to violate our broadcast-time
invariants without noticing and the panic gives us an opportunity
to catch it.

Sadly, in the case of 0conf channels, if we hadn't yet seen the
funding transaction at all but receive a block we would hit this
sanity check as we don't check whether there are actually funding
transaction confirmations prior to panicing.
lightning/src/ln/channel.rs
lightning/src/ln/priv_short_conf_tests.rs