]> git.bitcoin.ninja Git - rust-lightning/commit
Wait to create a channel until after accepting.
authorChris Waterson <waterson@gmail.com>
Tue, 18 Jul 2023 14:47:44 +0000 (07:47 -0700)
committerChris Waterson <waterson@gmail.com>
Mon, 14 Aug 2023 02:40:17 +0000 (19:40 -0700)
commit01847277b957ec94129141a7e7439ae539c094f1
tree5b49e2ddf7a78f35ad1fa696addc6c7e1a280d12
parent131560e08fa4f66b8ce9302cde637f87602c86b0
Wait to create a channel until after accepting.

Create a new table in 'peer_state' to maintain unaccepted inbound
channels; i.e., a channel for which we've received an 'open_channel'
message but that user code has not yet confirmed for acceptance. When
user code accepts the channel (e.g. via 'accept_inbound_channel'),
create the channel object and as before.

Currently, the 'open_channel' message eagerly creates an
InboundV1Channel object before determining if the channel should be
accepted. Because this happens /before/ the channel has been assigned
a user identity (which happens in the handler for OpenChannelRequest),
the channel is assigned a random user identity. As part of the
creation process, the channel's cryptographic material is initialized,
which then uses this randomly generated value for the user's channel
identity e.g. in SignerProvider::generate_channel_keys_id.

By delaying the creation of the InboundV1Channel until /after/ the
channel has been accepted, we ensure that we defer cryptographic
initialization until we have given the user the opportunity to assign
an identity to the channel.
lightning/src/events/mod.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/shutdown_tests.rs