From: Matt Corallo Date: Mon, 29 Nov 2021 20:05:35 +0000 (+0000) Subject: Fix regression when reading `Event::PaymentReceived` in some cases X-Git-Tag: v0.0.104~18^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=refs%2Fheads%2F2021-11-chanman-read-regression;p=rust-lightning 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. --- diff --git a/lightning/src/util/events.rs b/lightning/src/util/events.rs index e90f443b0..46ab9f749 100644 --- a/lightning/src/util/events.rs +++ b/lightning/src/util/events.rs @@ -476,7 +476,7 @@ impl MaybeReadable for Event { let mut payment_preimage = None; let mut payment_secret = None; let mut amt = 0; - let mut _user_payment_id = None; // For compatibility with 0.0.103 and earlier + let mut _user_payment_id = None::; // For compatibility with 0.0.103 and earlier read_tlv_fields!(reader, { (0, payment_hash, required), (2, payment_secret, option),