Fix regression when reading `Event::PaymentReceived` in some cases 2021-11-chanman-read-regression
authorMatt Corallo <git@bluematt.me>
Mon, 29 Nov 2021 20:05:35 +0000 (20:05 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 29 Nov 2021 21:03:12 +0000 (21:03 +0000)
commite62bd9d137e8e82ad38b820c7bd34b229b241fe9
treeba41834ef947ac0017c8a0f903a101be0f16b025
parent1a743672b92a65e3d401a11001354f3b514bf956
Fix regression when reading `Event::PaymentReceived` in some cases

For some reason rustc was deciding on a type for the `Option` being
deserialized for us as `_user_payment_id`. This really, really,
absolutely should have been a compile failure - the type (with
methods called on it!) was ambiguous! Instead, rustc seems to have
been defaulting to `Option<()>`, causing us to read zero of the
eight bytes in the `user_payment_id` field, which returns an
`Err(InvalidValue)` error as TLVs must always be read fully.

This should likely be reported to rustc as its definitely a bug,
but I cannot seem to cause the same error on any kinda of
vaguely-minimized version of the same code.

Found by `chanmon_consistency` fuzz target.
lightning/src/util/events.rs