Send initial closing_signed message asynchronously and handle errs
authorMatt Corallo <git@bluematt.me>
Mon, 19 Jul 2021 19:57:37 +0000 (19:57 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 17 Aug 2021 02:16:01 +0000 (02:16 +0000)
commit67ddd46aeded274caf44cc7a3f9f61975ebb1dd7
treecc8d214f06628bf0ac3096587a5d867e152df335
parentb1aa950f4fd0333465fb9193a7a70e4e20cd2abe
Send initial closing_signed message asynchronously and handle errs

When we added the support for external signing, many of the
signing functions were allowed to return an error, closing the
channel in such a case. `sign_closing_transaction` is one such
function which can now return an error, except instead of handling
it properly we'd simply never send a `closing_signed` message,
hanging the channel until users intervene and force-close it.

Piping the channel-closing error back through the various callsites
(several of which already have pending results by the time they
call `maybe_propose_first_closing_signed`) may be rather
complicated, so instead we simply attempt to propose the initial
`closing_signed` in `get_and_clear_pending_msg_events` like we do
for holding-cell freeing.

Further, since we now (possibly) generate a `ChannelMonitorUpdate`
on `shutdown`, we may need to wait for monitor updating to complete
before we can send a `closing_signed`, meaning we need to handle
the send asynchronously anyway.

This simplifies a few function interfaces and has no impact on
behavior, aside from a few message-ordering edge-cases, as seen in
the two small test changes required.
lightning/src/ln/chanmon_update_fail_tests.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_tests.rs