Fix bug where we encode flags field into all updates on htlc fail
[rust-lightning] / lightning / src / ln / channelmanager.rs
index e8aee263ae606be9af8ac6e06ab8f5ec13dddcca..47d6e1423bd8aa47d425364e0054ad97b34cb100 100644 (file)
@@ -4511,7 +4511,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
                                                                        onion_utils::build_first_hop_failure_packet(incoming_shared_secret, error_code, &{
                                                                                let mut res = Vec::with_capacity(8 + 128);
                                                                                // TODO: underspecified, follow https://github.com/lightningnetwork/lightning-rfc/issues/791
-                                                                               res.extend_from_slice(&byte_utils::be16_to_array(0));
+                                                                               if error_code == 0x1000 | 20 {
+                                                                                       res.extend_from_slice(&byte_utils::be16_to_array(0));
+                                                                               }
                                                                                res.extend_from_slice(&upd.encode_with_len()[..]);
                                                                                res
                                                                        }[..])