Skip to content

Commit e62bd9d

Browse files
committed
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.
1 parent 1a74367 commit e62bd9d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lightning/src/util/events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl MaybeReadable for Event {
476476
let mut payment_preimage = None;
477477
let mut payment_secret = None;
478478
let mut amt = 0;
479-
let mut _user_payment_id = None; // For compatibility with 0.0.103 and earlier
479+
let mut _user_payment_id = None::<u64>; // For compatibility with 0.0.103 and earlier
480480
read_tlv_fields!(reader, {
481481
(0, payment_hash, required),
482482
(2, payment_secret, option),

0 commit comments

Comments
 (0)