Do not panic on early tx broadcasts in fuzzing
[rust-lightning] / lightning / src / ln / channel.rs
index ca02f0a9ac9e302ae10047025097ff24c1fcc7cd..a54ef652b0679958dc26c8255dd0e5ae44caa3f4 100644 (file)
@@ -4652,9 +4652,17 @@ impl<Signer: Sign> Channel<Signer> {
                } else if non_shutdown_state == (ChannelState::FundingSent as u32 | ChannelState::OurChannelReady as u32) {
                        // We got a reorg but not enough to trigger a force close, just ignore.
                        false
-               } else if self.channel_state < ChannelState::ChannelFunded as u32 {
-                       panic!("Started confirming a channel in a state pre-FundingSent?: {}", self.channel_state);
                } else {
+                       if 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,
+                               // however, may do this and we shouldn't treat it as a bug.
+                               #[cfg(not(fuzzing))]
+                               panic!("Started confirming a channel in a state pre-FundingSent: {}.\n\
+                                       Do NOT broadcast a funding transaction manually - let LDK do it for you!",
+                                       self.channel_state);
+                       }
                        // We got a reorg but not enough to trigger a force close, just ignore.
                        false
                };