Merge pull request #1043 from jkczyz/2021-07-network-update-handler
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Wed, 15 Sep 2021 18:13:20 +0000 (18:13 +0000)
committerGitHub <noreply@github.com>
Wed, 15 Sep 2021 18:13:20 +0000 (18:13 +0000)
Handle network updates from failed payments in BackgroundProcessor

1  2 
lightning/src/ln/channel.rs

index 8ed7072dd8aafe1ec79871255676084f797cd089,7f84ecf3e599e8919f9d765f2003edcaf29a3c57..930511c0dd4c3c211fefc1b94259851ef191d0c7
@@@ -454,8 -454,8 +454,8 @@@ pub(super) struct Channel<Signer: Sign
        /// closing_signed message and handling it in `maybe_propose_closing_signed`.
        pending_counterparty_closing_signed: Option<msgs::ClosingSigned>,
  
 -      /// The minimum and maximum absolute fee we are willing to place on the closing transaction.
 -      /// These are set once we reach `closing_negotiation_ready`.
 +      /// The minimum and maximum absolute fee, in satoshis, we are willing to place on the closing
 +      /// transaction. These are set once we reach `closing_negotiation_ready`.
        #[cfg(test)]
        pub(crate) closing_fee_limits: Option<(u64, u64)>,
        #[cfg(not(test))]
@@@ -2178,7 -2178,7 +2178,7 @@@ impl<Signer: Sign> Channel<Signer> 
                // 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 {
-                       pending_forward_status = create_pending_htlc_status(self, pending_forward_status, 0x1000|20);
+                       pending_forward_status = create_pending_htlc_status(self, pending_forward_status, 0x4000|8);
                }
                // 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);
                                cmp::max(normal_feerate as u64 * tx_weight / 1000 + self.config.force_close_avoidance_max_fee_satoshis,
                                        proposed_max_feerate as u64 * tx_weight / 1000)
                        } else {
 -                              u64::max_value()
 +                              self.channel_value_satoshis - (self.value_to_self_msat + 999) / 1000
                        };
  
                self.closing_fee_limits = Some((proposed_total_fee_satoshis, proposed_max_total_fee_satoshis));
  
                        if !self.is_outbound() {
                                // They have to pay, so pick the highest fee in the overlapping range.
 -                              debug_assert_eq!(our_max_fee, u64::max_value()); // We should never set an upper bound
 +                              // We should never set an upper bound aside from their full balance
 +                              debug_assert_eq!(our_max_fee, self.channel_value_satoshis - (self.value_to_self_msat + 999) / 1000);
                                propose_fee!(cmp::min(max_fee_satoshis, our_max_fee));
                        } else {
                                if msg.fee_satoshis < our_min_fee || msg.fee_satoshis > our_max_fee {