Fix panic when peer is mid-handshake
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 18 Jan 2024 21:34:19 +0000 (15:34 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Mon, 22 Jan 2024 21:35:47 +0000 (15:35 -0600)
commitc7465bdb3e138def94f77848671567b24991345b
treed501791857a557edeb50bf4bdbfd9080017777f1
parent5592378de27eb7453ccc70ac2d0b5c8d9b10e091
Fix panic when peer is mid-handshake

Peer::their_node_id is set to Some during the handshake process.
However, df3ab2ee2753e7f9ec02ddf1c8a51db77c50e35d accesses the field
unconditionally, causing a panic. This may be triggered if a gossip
message is received mid-handshake from another peer or if the user calls
broadcast_node_announcement during this time. The latter tends to be
executed on a timer.

Ensure that Peer::their_node_id is only accessed once the handshake is
complete.
lightning/src/ln/peer_handler.rs