Reject minimum_depth of 0 on channel opens
authorMatt Corallo <git@bluematt.me>
Sun, 4 Jul 2021 14:13:45 +0000 (14:13 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 4 Jul 2021 14:17:26 +0000 (14:17 +0000)
We don't support turbo channels so this is a pretty clear
indication that there is some incompatibility.

lightning/src/ln/channel.rs

index 4051ebf3fbf6cc0d07dd29c4132c2dab3510bb43..a39e453c1731da79ca55fde0f3c1397840efd05c 100644 (file)
@@ -1488,6 +1488,12 @@ impl<Signer: Sign> Channel<Signer> {
                if msg.minimum_depth > config.peer_channel_config_limits.max_minimum_depth {
                        return Err(ChannelError::Close(format!("We consider the minimum depth to be unreasonably large. Expected minimum: ({}). Actual: ({})", config.peer_channel_config_limits.max_minimum_depth, msg.minimum_depth)));
                }
+               if msg.minimum_depth == 0 {
+                       // Note that if this changes we should update the serialization minimum version to
+                       // indicate to older clients that they don't understand some features of the current
+                       // channel.
+                       return Err(ChannelError::Close("Minimum confirmation depth must be at least 1".to_owned()));
+               }
 
                let counterparty_shutdown_scriptpubkey = if their_features.supports_upfront_shutdown_script() {
                        match &msg.shutdown_scriptpubkey {