From 968720344ca5dfdfa4faabdd92ae2b9232ef97e6 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 4 Nov 2018 12:56:54 +1100 Subject: [PATCH] Panic if funding transaction has non-witness inputs --- src/ln/channel.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 25e981d7d..e56fbd532 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -2827,6 +2827,16 @@ impl Channel { self.channel_update_count += 1; return Err(HandleError{err: "funding tx had wrong script/value", action: Some(ErrorAction::DisconnectPeer{msg: None})}); } else { + if self.channel_outbound { + for input in tx.input.iter() { + if input.witness.is_empty() { + // We generated a malleable funding transaction, implying we've + // just exposed ourselves to funds loss to our counterparty. + #[cfg(not(feature = "fuzztarget"))] + panic!("Client called ChannelManager::funding_transaction_generated with bogus transaction!"); + } + } + } self.funding_tx_confirmations = 1; self.short_channel_id = Some(((height as u64) << (5*8)) | ((*index_in_block as u64) << (2*8)) | -- 2.39.5