Panic if funding transaction has non-witness inputs 2018-11-misc-tweaks
authorMatt Corallo <git@bluematt.me>
Sun, 4 Nov 2018 01:56:54 +0000 (12:56 +1100)
committerMatt Corallo <git@bluematt.me>
Thu, 15 Nov 2018 17:25:09 +0000 (12:25 -0500)
src/ln/channel.rs

index 25e981d7daa3e170c3214254b9303da0d2edf2e9..e56fbd53228be08a73b86a596571ffde0435a703 100644 (file)
@@ -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)) |