]> git.bitcoin.ninja Git - rust-lightning/commit
Delay creating outbound ChannelMonitor until funding_signed rcpt
authorMatt Corallo <git@bluematt.me>
Sat, 18 Apr 2020 20:35:01 +0000 (16:35 -0400)
committerMatt Corallo <git@bluematt.me>
Thu, 23 Apr 2020 17:34:57 +0000 (13:34 -0400)
commit5d0bfa383425ecbf308fdf819dbf7ad19e6c5ca4
tree273cca658d91be1a195de0ff6b2fb9ed9edd78f2
parent3ea13194e8ad3ea3493ca4ba63cd215eee105feb
Delay creating outbound ChannelMonitor until funding_signed rcpt

Previously, we created the initial ChannelMonitor on outbound
channels when we generated the funding_created message. This was
somewhat unnecessary as, at that time, we hadn't yet received
clearance to broadcast our initial funding transaction, and thus
there should never be any use for a ChannelMonitor. It also
complicated ChannelMonitor a bit as, at this point, we didn't have
an initial local commitment transaction.

By moving the creation of the initial ChannelMonitor to when we
receive our counterparty's funding_signed, we can ensure that any
ChannelMonitor will always have both a latest remote commitment tx
and a latest local commitment tx for broadcast.

This also fixes a strange API where we would close a channel
unceremoniously on peer-disconnection if we hadn't yet received the
funding_signed, but we'd already have a ChannelMonitor for that
channel. While it isn't strictly a bug (some potential DoS issues
aside), it is strange that these two definitions of a channel being
open were not in sync.
lightning/src/ln/chanmon_update_fail_tests.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs