Add missing deserialization of Event::HTLCHandlingFailed 2022-09-missing-event-deser
authorMatt Corallo <git@bluematt.me>
Tue, 6 Sep 2022 22:51:29 +0000 (22:51 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 7 Sep 2022 21:57:10 +0000 (21:57 +0000)
17e6c374c513f2eca810fa4e931be65f0d4fc29f added the
`HTLCHandlingFailed` event, including serialization thereof,
however failed to add corresponding deserialization. This corrects
that oversight by adding said deserialization.

Thanks to @wpaulino for catching the oversight.

lightning/src/util/events.rs

index e86eae3c813a8af7a3684480171df913ea0883bd..099fea60eda7127b34a83d6c40792591c029dd3b 100644 (file)
@@ -1002,7 +1002,7 @@ impl MaybeReadable for Event {
                                                (4, path, vec_type),
                                                (6, short_channel_id, option),
                                        });
-                                       Ok(Some(Event::ProbeFailed{
+                                       Ok(Some(Event::ProbeFailed {
                                                payment_id,
                                                payment_hash,
                                                path: path.unwrap(),
@@ -1011,6 +1011,28 @@ impl MaybeReadable for Event {
                                };
                                f()
                        },
+                       25u8 => {
+                               let f = || {
+                                       let mut prev_channel_id = [0; 32];
+                                       let mut failed_next_destination_opt = None;
+                                       read_tlv_fields!(reader, {
+                                               (0, prev_channel_id, required),
+                                               (2, failed_next_destination_opt, ignorable),
+                                       });
+                                       if let Some(failed_next_destination) = failed_next_destination_opt {
+                                               Ok(Some(Event::HTLCHandlingFailed {
+                                                       prev_channel_id,
+                                                       failed_next_destination,
+                                               }))
+                                       } else {
+                                               // If we fail to read a `failed_next_destination` assume it's because
+                                               // `MaybeReadable::read` returned `Ok(None)`, though it's also possible we
+                                               // were simply missing the field.
+                                               Ok(None)
+                                       }
+                               };
+                               f()
+                       },
                        // Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
                        // Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
                        // reads.