]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Avoid `unwrap`ing in `get_announcement_sigs`
authorElias Rohrer <dev@tnull.de>
Sat, 17 Jun 2023 11:17:20 +0000 (13:17 +0200)
committerElias Rohrer <dev@tnull.de>
Fri, 21 Jul 2023 07:54:28 +0000 (09:54 +0200)
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

index eb92712c5612d8b390db1e1aaa74c57c7eafbf22..6df539b537cff8035f50a4625317c785f8cb31f3 100644 (file)
@@ -4900,11 +4900,16 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
                        },
                        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,
                })