From f9c945e17fd39c7a7250b18f0053798e0b92c19d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 2 Dec 2018 18:22:40 -0500 Subject: [PATCH] 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. --- src/ln/channelmonitor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()); -- 2.39.5