From: Matt Corallo Date: Thu, 23 Aug 2018 17:54:34 +0000 (-0400) Subject: Return channel_updates when failing a HTLC for fee/CLTV reasons X-Git-Tag: v0.0.12~344^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=6ab31a0d501db9fd96436deff190da8801ac73b7;p=rust-lightning Return channel_updates when failing a HTLC for fee/CLTV reasons --- diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index 73b4ecca3..27f470d40 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -1657,14 +1657,14 @@ impl ChannelMessageHandler for ChannelManager { let fee = chan.get_our_fee_base_msat(&*self.fee_estimator) + (pending_forward_info.amt_to_forward * self.fee_proportional_millionths as u64 / 1000000) as u32; if msg.amount_msat < fee as u64 || (msg.amount_msat - fee as u64) < pending_forward_info.amt_to_forward { log_debug!(self, "HTLC {} incorrect amount: in {} out {} fee required {}", msg.htlc_id, msg.amount_msat, pending_forward_info.amt_to_forward, fee); - //TODO: send back "channel_update" with new fee parameters in onion failure packet - return_err!("Prior hop has deviated from specified fees parameters or origin node has obsolete ones", 0x1000 | 12, &[0;0]); + let chan_update = self.get_channel_update(chan).unwrap(); + return_err!("Prior hop has deviated from specified fees parameters or origin node has obsolete ones", 0x1000 | 12, &chan_update.encode_with_len()[..]); } if (msg.cltv_expiry as u64) < pending_forward_info.outgoing_cltv_value as u64 + CLTV_EXPIRY_DELTA as u64 { log_debug!(self, "HTLC {} incorrect CLTV: in {} out {} delta required {}", msg.htlc_id, msg.cltv_expiry, pending_forward_info.outgoing_cltv_value, CLTV_EXPIRY_DELTA); - return_err!("Forwarding node has tampered with the intended HTLC values or origin node has an obsolete cltv_expiry_delta", 0x1000 | 13, &[0;0]); + let chan_update = self.get_channel_update(chan).unwrap(); + return_err!("Forwarding node has tampered with the intended HTLC values or origin node has an obsolete cltv_expiry_delta", 0x1000 | 13, &chan_update.encode_with_len()[..]); } - if !chan.is_live() { let chan_update = self.get_channel_update(chan).unwrap(); return_err!("Forwarding channel is not in a ready state.", 0x1000 | 7, &chan_update.encode_with_len()[..]);