X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Futil%2Fconfig.rs;h=e1a7e59727cc14d0f6cb9c1ca545b91ead628bae;hb=4769b944de50f3819b4252353345009b1d810e90;hp=a3abdbedeecc9e88174899b05b76330dda22ce22;hpb=827a5255ff71a6e1a61b068ffba89b3da5d4ad5e;p=rust-lightning diff --git a/src/util/config.rs b/src/util/config.rs index a3abdbed..e1a7e597 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -4,8 +4,10 @@ /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig. #[derive(Clone, Debug)] pub struct UserConfig { - /// Limits applied during channel creation. - pub channel_limits: ChannelHandshakeLimits, + /// 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, } @@ -14,12 +16,31 @@ impl UserConfig { /// Provides sane defaults for most configurations (but with 0 relay fees!) pub fn new() -> Self{ UserConfig { - channel_limits: ChannelHandshakeLimits::new(), + own_channel_config: ChannelHandshakeConfig::new(), + peer_channel_config_limits: ChannelHandshakeLimits::new(), channel_options: ChannelConfig::new(), } } } +/// Configuration we set when applicable. +#[derive(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 + /// equivalent limit applied to outbound channels). + pub minimum_depth: u32, +} + +impl ChannelHandshakeConfig { + /// Provides sane defaults for `ChannelHandshakeConfig` + pub fn new() -> ChannelHandshakeConfig { + ChannelHandshakeConfig { + minimum_depth: 6, + } + } +} + /// Optional channel limits which are applied during channel creation. /// /// These limits are only applied to our counterparty's limits, not our own. @@ -108,6 +129,14 @@ pub struct ChannelConfig { /// /// This cannot be changed after the initial channel handshake. pub announced_channel: bool, + /// Set to commit to an upfront shutdown_pubkey at channel opening. In case of mutual + /// closing, the other peer will check that our closing transction output is encumbered + /// by the provided script. + /// + /// We set it by default as this ensure greater security to the user funds. + /// + /// This cannot be changed after channel opening. + pub commit_upfront_shutdown_pubkey: bool } impl ChannelConfig { @@ -116,12 +145,14 @@ impl ChannelConfig { ChannelConfig { fee_proportional_millionths: 0, announced_channel: false, + commit_upfront_shutdown_pubkey: true, } } } //Add write and readable traits to channelconfig -impl_writeable!(ChannelConfig, 8+1, { +impl_writeable!(ChannelConfig, 8+1+1, { fee_proportional_millionths, - announced_channel + announced_channel, + commit_upfront_shutdown_pubkey });