Merge pull request #1711 from TheBlueMatt/2022-08-0conf-panic
[rust-lightning] / lightning / src / ln / channel.rs
index 624f4d6b688b0e2d81964d39e2deb77e1233af8a..b37550b0d2a91eb909bb997dc3dda39a91de887b 100644 (file)
@@ -4771,6 +4771,9 @@ impl<Signer: Sign> Channel<Signer> {
        }
 
        fn check_get_channel_ready(&mut self, height: u32) -> Option<msgs::ChannelReady> {
+               // Called:
+               //  * always when a new block/transactions are confirmed with the new height
+               //  * when funding is signed with a height of 0
                if self.funding_tx_confirmation_height == 0 && self.minimum_depth != Some(0) {
                        return None;
                }
@@ -4796,7 +4799,7 @@ impl<Signer: Sign> Channel<Signer> {
                        // We got a reorg but not enough to trigger a force close, just ignore.
                        false
                } else {
-                       if self.channel_state < ChannelState::ChannelFunded as u32 {
+                       if self.funding_tx_confirmation_height != 0 && self.channel_state < ChannelState::ChannelFunded as u32 {
                                // We should never see a funding transaction on-chain until we've received
                                // funding_signed (if we're an outbound channel), or seen funding_generated (if we're
                                // an inbound channel - before that we have no known funding TXID). The fuzzer,