Raise max to_self_delay.
[rust-lightning] / lightning / src / util / config.rs
index 3c4ab77c16bc1d921d6057c21bb620fe410dce68..19c4562105bff3aa15b1d6f88099a8da42a33669 100644 (file)
@@ -1,36 +1,21 @@
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
 //! Various user-configurable channel limits and settings which ChannelManager
 //! applies for you.
 
 use ln::channelmanager::{BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT};
 
-/// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
-///
-/// Default::default() provides sane defaults for most configurations
-/// (but currently with 0 relay fees!)
-#[derive(Clone, Debug)]
-pub struct UserConfig {
-       /// Channel config that we propose to our counterparty.
-       pub own_channel_config: ChannelHandshakeConfig,
-       /// Limits applied to our counterparty's proposed channel config settings.
-       pub peer_channel_config_limits: ChannelHandshakeLimits,
-       /// Channel config which affects behavior during channel lifetime.
-       pub channel_options: ChannelConfig,
-}
-
-impl Default for UserConfig {
-       fn default() -> Self {
-               UserConfig {
-                       own_channel_config: ChannelHandshakeConfig::default(),
-                       peer_channel_config_limits: ChannelHandshakeLimits::default(),
-                       channel_options: ChannelConfig::default(),
-               }
-       }
-}
-
 /// Configuration we set when applicable.
 ///
 /// Default::default() provides sane defaults.
-#[derive(Clone, Debug)]
+#[derive(Copy, Clone, Debug)]
 pub struct ChannelHandshakeConfig {
        /// Confirmations we will wait for before considering the channel locked in.
        /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
@@ -51,6 +36,14 @@ pub struct ChannelHandshakeConfig {
        /// Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel
        /// opening so you can tweak config to ask for more security, not less.
        pub our_to_self_delay: u16,
+       /// Set to the smallest value HTLC we will accept to process.
+       ///
+       /// This value is sent to our counterparty on channel-open and we close the channel any time
+       /// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
+       ///
+       /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
+       /// by the protocol.
+       pub our_htlc_minimum_msat: u64,
 }
 
 impl Default for ChannelHandshakeConfig {
@@ -58,6 +51,7 @@ impl Default for ChannelHandshakeConfig {
                ChannelHandshakeConfig {
                        minimum_depth: 6,
                        our_to_self_delay: BREAKDOWN_TIMEOUT,
+                       our_htlc_minimum_msat: 1,
                }
        }
 }
@@ -135,8 +129,8 @@ pub struct ChannelHandshakeLimits {
        /// Not checking this value would be a security issue, as our peer would be able to set it to
        /// max relative lock-time (a year) and we would "lose" money as it would be locked for a long time.
        ///
-       /// Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value
-       /// so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
+       /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
+       /// reduce the loss of having useless locked funds (if your peer accepts)
        pub their_to_self_delay: u16
 }
 
@@ -210,3 +204,27 @@ impl_writeable!(ChannelConfig, 8+1+1, {
        announced_channel,
        commit_upfront_shutdown_pubkey
 });
+
+/// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
+///
+/// Default::default() provides sane defaults for most configurations
+/// (but currently with 0 relay fees!)
+#[derive(Copy, Clone, Debug)]
+pub struct UserConfig {
+       /// Channel config that we propose to our counterparty.
+       pub own_channel_config: ChannelHandshakeConfig,
+       /// Limits applied to our counterparty's proposed channel config settings.
+       pub peer_channel_config_limits: ChannelHandshakeLimits,
+       /// Channel config which affects behavior during channel lifetime.
+       pub channel_options: ChannelConfig,
+}
+
+impl Default for UserConfig {
+       fn default() -> Self {
+               UserConfig {
+                       own_channel_config: ChannelHandshakeConfig::default(),
+                       peer_channel_config_limits: ChannelHandshakeLimits::default(),
+                       channel_options: ChannelConfig::default(),
+               }
+       }
+}