Fix `Route` serialization round-trip
authorMatt Corallo <git@bluematt.me>
Fri, 16 Feb 2024 19:26:22 +0000 (19:26 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 9 Apr 2024 15:01:41 +0000 (15:01 +0000)
When the `max_total_routing_fee_msat` parameter was added to
`RouteParameters`, the serialization used `map` to get the max fee,
accidentally writing an `Option<Option<u64>>`, but then read it as
an `Option<u64>`. Thus, any `Route`s with a `route_params` written
will fail to be read back.

Luckily, this is an incredibly rarely-used bit of code, so only one
user managed to hit it.

lightning/src/routing/router.rs

index 42556ff3400fe8215064822cd954003f058b9e71..1dbd1ffc655569187459d45e822803839a9eda0e 100644 (file)
@@ -529,7 +529,7 @@ impl Writeable for Route {
                        (1, self.route_params.as_ref().map(|p| &p.payment_params), option),
                        (2, blinded_tails, optional_vec),
                        (3, self.route_params.as_ref().map(|p| p.final_value_msat), option),
-                       (5, self.route_params.as_ref().map(|p| p.max_total_routing_fee_msat), option),
+                       (5, self.route_params.as_ref().and_then(|p| p.max_total_routing_fee_msat), option),
                });
                Ok(())
        }