Merge pull request #265 from TheBlueMatt/2018-12-fuzz-fix-no-witness
[rust-lightning] / src / ln / channelmonitor.rs
index 6ce4b22d5a8c63109765be350c53883ad9d91855..cee406d000ef41f763d6853df4b70bce9396948c 100644 (file)
@@ -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<SpendableOutputDescriptor> {
-               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());