Fix bug in Channel
[rust-lightning] / lightning / src / ln / channel.rs
index b8f297c45bc075eb413d6ead88c37afc91e79e09..2bea55a57bc404a51d7ad20d3b2f0d1e2454cd9d 100644 (file)
@@ -1696,8 +1696,8 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
        /// corner case properly.
        pub fn get_inbound_outbound_available_balance_msat(&self) -> (u64, u64) {
                // Note that we have to handle overflow due to the above case.
-               (cmp::min(self.channel_value_satoshis as i64 * 1000 - self.value_to_self_msat as i64 - self.get_inbound_pending_htlc_stats().1 as i64, 0) as u64,
-               cmp::min(self.value_to_self_msat as i64 - self.get_outbound_pending_htlc_stats().1 as i64, 0) as u64)
+               (cmp::max(self.channel_value_satoshis as i64 * 1000 - self.value_to_self_msat as i64 - self.get_inbound_pending_htlc_stats().1 as i64, 0) as u64,
+               cmp::max(self.value_to_self_msat as i64 - self.get_outbound_pending_htlc_stats().1 as i64, 0) as u64)
        }
 
        // Get the fee cost of a commitment tx with a given number of HTLC outputs.