From: Matt Corallo Date: Sun, 2 Dec 2018 23:22:40 +0000 (-0500) Subject: Fix crash on no-witness tx in ChannelMonitor found by fuzzer X-Git-Tag: v0.0.12~261^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=f9c945e17fd39c7a7250b18f0053798e0b92c19d;p=rust-lightning Fix crash on no-witness tx in ChannelMonitor found by fuzzer Tehnically we can't currently hit this, but a theoretical future watchtower could, and full_stack_target crashes on it. --- diff --git a/src/ln/channelmonitor.rs b/src/ln/channelmonitor.rs index 6ce4b22d5..cee406d00 100644 --- a/src/ln/channelmonitor.rs +++ b/src/ln/channelmonitor.rs @@ -1386,7 +1386,7 @@ impl ChannelMonitor { /// Generate a spendable output event when closing_transaction get registered onchain. fn check_spend_closing_transaction(&self, tx: &Transaction) -> Option { - if tx.input[0].sequence == 0xFFFFFFFF && tx.input[0].witness.last().unwrap().len() == 71 { + if tx.input[0].sequence == 0xFFFFFFFF && !tx.input[0].witness.is_empty() && tx.input[0].witness.last().unwrap().len() == 71 { match self.key_storage { KeyStorage::PrivMode { ref shutdown_pubkey, .. } => { let our_channel_close_key_hash = Hash160::from_data(&shutdown_pubkey.serialize());