From adcac97ebc5ba6a1a74684bc59c7710b9918bcff Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Sat, 17 Jun 2023 13:17:20 +0200 Subject: [PATCH] Avoid `unwrap`ing in `get_announcement_sigs` While this is currently not reachable, it's still cleaner to avoid the `unwrap` and return `None` if `short_channel_id` hasn't been set yet. --- lightning/src/ln/channel.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index eb92712c5..6df539b53 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -4900,11 +4900,16 @@ impl Channel { }, Ok(v) => v }; + let short_channel_id = match self.context.get_short_channel_id() { + Some(scid) => scid, + None => return None, + }; + self.context.announcement_sigs_state = AnnouncementSigsState::MessageSent; Some(msgs::AnnouncementSignatures { channel_id: self.context.channel_id(), - short_channel_id: self.context.get_short_channel_id().unwrap(), + short_channel_id, node_signature: our_node_sig, bitcoin_signature: our_bitcoin_sig, }) -- 2.39.5