From: Elias Rohrer Date: Sat, 17 Jun 2023 11:17:20 +0000 (+0200) Subject: Avoid `unwrap`ing in `get_announcement_sigs` X-Git-Tag: v0.0.116~2^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=adcac97ebc5ba6a1a74684bc59c7710b9918bcff;p=rust-lightning 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. --- 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, })