]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Avoid an unnecessary unwrap
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 18 May 2023 18:15:00 +0000 (13:15 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Tue, 13 Jun 2023 18:07:47 +0000 (13:07 -0500)
lightning/src/onion_message/packet.rs

index 9322f9489bcd42d80f5dfc6161650dedd1f0f15b..e5fb93f4501ec5e175039c4385518c2230449b3c 100644 (file)
@@ -250,13 +250,12 @@ ReadableArgs<(SharedSecret, &H, &L)> for Payload<<H as CustomOnionMessageHandler
                                Ok(Payload::Forward(ForwardControlTlvs::Unblinded(tlvs)))
                        },
                        Some(ChaChaPolyReadAdapter { readable: ControlTlvs::Receive(tlvs)}) => {
-                               if message.is_none() { return Err(DecodeError::InvalidValue) }
                                Ok(Payload::Receive {
                                        control_tlvs: ReceiveControlTlvs::Unblinded(tlvs),
                                        reply_path,
-                                       message: message.unwrap(),
+                                       message: message.ok_or(DecodeError::InvalidValue)?,
                                })
-                       }
+                       },
                }
        }
 }