Skip to content

Commit 47045b0

Browse files
committed
Do not panic on early tx broadcasts in fuzzing
If the user broadcasts a funding transaction before the counterparty provides a `funding_signed` we will panic in `check_get_channel_ready`. This is expected - the user did something which may lead to loss of funds, and we *really* need to let them know. However, the fuzzer can do this and we shouldn't treat it as a bug, its a totally expected panic. Thus, we disable the panic in fuzz. Thanks to Chaincode for providing fuzzing resources which managed to hit this panic.
1 parent 0b77008 commit 47045b0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lightning/src/ln/channel.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -4652,9 +4652,17 @@ impl<Signer: Sign> Channel<Signer> {
46524652
} else if non_shutdown_state == (ChannelState::FundingSent as u32 | ChannelState::OurChannelReady as u32) {
46534653
// We got a reorg but not enough to trigger a force close, just ignore.
46544654
false
4655-
} else if self.channel_state < ChannelState::ChannelFunded as u32 {
4656-
panic!("Started confirming a channel in a state pre-FundingSent?: {}", self.channel_state);
46574655
} else {
4656+
if self.channel_state < ChannelState::ChannelFunded as u32 {
4657+
// We should never see a funding transaction on-chain until we've received
4658+
// funding_signed (if we're an outbound channel), or seen funding_generated (if we're
4659+
// an inbound channel - before that we have no known funding TXID). The fuzzer,
4660+
// however, may do this and we shouldn't treat it as a bug.
4661+
#[cfg(not(fuzzing))]
4662+
panic!("Started confirming a channel in a state pre-FundingSent: {}.\n\
4663+
Do NOT broadcast a funding transaction manually - let LDK do it for you!",
4664+
self.channel_state);
4665+
}
46584666
// We got a reorg but not enough to trigger a force close, just ignore.
46594667
false
46604668
};

0 commit comments

Comments
 (0)