Correctly include the `sha256_hash_of_onion` field in BADONION errs
authorMatt Corallo <git@bluematt.me>
Thu, 1 Dec 2022 20:30:45 +0000 (20:30 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 6 Dec 2022 20:00:44 +0000 (20:00 +0000)
The spec mandates that we copy the `sha256_hash_of_onion` field
from the `UpdateFailMalformedHTLC` message into the error message
we send back to the sender, however we simply ignored it. Here we
copy it into the message correctly.

lightning/src/ln/channelmanager.rs

index 36886645ab88c7e94924b59bf25137b2a6cb303c..9ec1c43cfa366b48a7f4a035d156281e9b37b86a 100644 (file)
@@ -5076,7 +5076,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
                                        let chan_err: ChannelError = ChannelError::Close("Got update_fail_malformed_htlc with BADONION not set".to_owned());
                                        try_chan_entry!(self, Err(chan_err), chan);
                                }
-                               try_chan_entry!(self, chan.get_mut().update_fail_malformed_htlc(&msg, HTLCFailReason::from_failure_code(msg.failure_code)), chan);
+                               try_chan_entry!(self, chan.get_mut().update_fail_malformed_htlc(&msg, HTLCFailReason::reason(msg.failure_code, msg.sha256_of_onion.to_vec())), chan);
                                Ok(())
                        },
                        hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close("Failed to find corresponding channel".to_owned(), msg.channel_id))