Correct initial commitment check in inbound channel-open handling.
[rust-lightning] / lightning / src / ln / channel.rs
index 151564e556dc76bc3da752b4875ce0a3636c76a9..f2f1ad766a9a195ff2306379c18cf9c878f6704f 100644 (file)
@@ -652,9 +652,10 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                        return Err(ChannelError::Close("Insufficient funding amount for initial commitment"));
                }
 
-               let to_local_msat = msg.push_msat;
                let to_remote_msat = funders_amount_msat - background_feerate * COMMITMENT_TX_BASE_WEIGHT;
-               if to_local_msat <= msg.channel_reserve_satoshis * 1000 && to_remote_msat <= remote_channel_reserve_satoshis * 1000 {
+               // While its reasonable for us to not meet the channel reserve initially (if they don't
+               // want to push much to us), our counterparty should always have more than the reserve.
+               if to_remote_msat <= remote_channel_reserve_satoshis * 1000 {
                        return Err(ChannelError::Close("Insufficient funding amount for initial commitment"));
                }
 
@@ -2493,6 +2494,7 @@ debug_assert!(false, "This should be triggerable, and we should add a test case
                let commitment_update = if self.monitor_pending_commitment_signed {
                        Some(self.get_last_commitment_update(logger))
                } else { None };
+//XXX: Should we free_holding_cell_htlcs() here if we dont need a cs normally?
 
                self.monitor_pending_revoke_and_ack = false;
                self.monitor_pending_commitment_signed = false;