+ if i > ::std::u16::MAX as usize {
+ // While it is possible that an output exists on chain which is greater than the
+ // 2^16th output in a given transaction, this is only possible if the output is not
+ // in a lightning transaction and was instead placed there by some third party who
+ // wishes to give us money for no reason.
+ // Namely, any lightning transactions which we pre-sign will never have anywhere
+ // near 2^16 outputs both because such transactions must have ~2^16 outputs who's
+ // scripts are not longer than one byte in length and because they are inherently
+ // non-standard due to their size.
+ // Thus, it is completely safe to ignore such outputs, and while it may result in
+ // us ignoring non-lightning fund to us, that is only possible if someone fills
+ // nearly a full block with garbage just to hit this case.
+ continue;
+ }