diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 3a1463d23c0..93404f1bb1e 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -1733,17 +1733,12 @@ impl Channel { self.commit_tx_fee_msat(their_acked_htlcs + addl_htlcs) } - pub fn update_add_htlc(&mut self, msg: &msgs::UpdateAddHTLC, mut pending_forward_state: PendingHTLCStatus, create_pending_htlc_status: F) -> Result<(), ChannelError> + pub fn update_add_htlc(&mut self, msg: &msgs::UpdateAddHTLC, mut pending_forward_status: PendingHTLCStatus, create_pending_htlc_status: F) -> Result<(), ChannelError> where F: for<'a> Fn(&'a Self, PendingHTLCStatus, u16) -> PendingHTLCStatus { // We can't accept HTLCs sent after we've sent a shutdown. let local_sent_shutdown = (self.channel_state & (ChannelState::ChannelFunded as u32 | ChannelState::LocalShutdownSent as u32)) != (ChannelState::ChannelFunded as u32); if local_sent_shutdown { - // TODO: Note that |20 is defined as "channel FROM the processing - // node has been disabled" (emphasis mine), which seems to imply - // that we can't return |20 for an inbound channel being disabled. - // This probably needs a spec update but should definitely be - // allowed. - pending_forward_state = create_pending_htlc_status(self, pending_forward_state, 0x1000|20); + pending_forward_status = create_pending_htlc_status(self, pending_forward_status, 0x1000|20); } // If the remote has sent a shutdown prior to adding this HTLC, then they are in violation of the spec. let remote_sent_shutdown = (self.channel_state & (ChannelState::ChannelFunded as u32 | ChannelState::RemoteShutdownSent as u32)) != (ChannelState::ChannelFunded as u32); @@ -1823,9 +1818,9 @@ impl Channel { // being sensitive to fee spikes. let remote_fee_cost_incl_stuck_buffer_msat = 2 * self.next_remote_commit_tx_fee_msat(1 + 1); if pending_remote_value_msat - msg.amount_msat - chan_reserve_msat < remote_fee_cost_incl_stuck_buffer_msat { - // Note that if the pending_forward_state is not updated here, then it's because we're already failing + // Note that if the pending_forward_status is not updated here, then it's because we're already failing // the HTLC, i.e. its status is already set to failing. - pending_forward_state = create_pending_htlc_status(self, pending_forward_state, 0x1000|7); + pending_forward_status = create_pending_htlc_status(self, pending_forward_status, 0x1000|7); } } else { // Check that they won't violate our local required channel reserve by adding this HTLC. @@ -1845,7 +1840,7 @@ impl Channel { } if self.channel_state & ChannelState::LocalShutdownSent as u32 != 0 { - if let PendingHTLCStatus::Forward(_) = pending_forward_state { + if let PendingHTLCStatus::Forward(_) = pending_forward_status { panic!("ChannelManager shouldn't be trying to add a forwardable HTLC after we've started closing"); } } @@ -1857,7 +1852,7 @@ impl Channel { amount_msat: msg.amount_msat, payment_hash: msg.payment_hash, cltv_expiry: msg.cltv_expiry, - state: InboundHTLCState::RemoteAnnounced(pending_forward_state), + state: InboundHTLCState::RemoteAnnounced(pending_forward_status), }); Ok(()) }