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

lightning-block-sync/Cargo.toml
lightning/src/ln/channel.rs

index 2a8ff0c6a1807f91d07f71a64969343328812c81..0902cc3206905c5ed496a85eb4745a25d6db0264 100644 (file)
@@ -20,7 +20,6 @@ tokio = { version = "1.0", features = [ "io-util", "net", "time" ], optional = t
 serde = { version = "1.0", features = ["derive"], optional = true }
 serde_json = { version = "1.0", optional = true }
 chunked_transfer = { version = "1.4", optional = true }
-futures = { version = "0.3" }
 
 [dev-dependencies]
 tokio = { version = "1.0", features = [ "macros", "rt" ] }
index 7f84ecf3e599e8919f9d765f2003edcaf29a3c57..930511c0dd4c3c211fefc1b94259851ef191d0c7 100644 (file)
@@ -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))]
@@ -3414,7 +3414,7 @@ impl<Signer: Sign> Channel<Signer> {
                                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));
@@ -3701,7 +3701,8 @@ impl<Signer: Sign> Channel<Signer> {
 
                        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 {