use ln::channelmanager::{BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT};
#[derive(Copy, Clone, Debug)]
pub struct ChannelHandshakeConfig {
pub minimum_depth: u32,
pub our_to_self_delay: u16,
pub our_htlc_minimum_msat: u64,
}
impl Default for ChannelHandshakeConfig {
fn default() -> ChannelHandshakeConfig {
ChannelHandshakeConfig {
minimum_depth: 6,
our_to_self_delay: BREAKDOWN_TIMEOUT,
our_htlc_minimum_msat: 1,
}
}
}
#[derive(Copy, Clone, Debug)]
pub struct ChannelHandshakeLimits {
pub min_funding_satoshis: u64,
pub max_htlc_minimum_msat: u64,
pub min_max_htlc_value_in_flight_msat: u64,
pub max_channel_reserve_satoshis: u64,
pub min_max_accepted_htlcs: u16,
pub max_minimum_depth: u32,
pub force_announced_channel_preference: bool,
pub their_to_self_delay: u16
}
impl Default for ChannelHandshakeLimits {
fn default() -> Self {
ChannelHandshakeLimits {
min_funding_satoshis: 0,
max_htlc_minimum_msat: <u64>::max_value(),
min_max_htlc_value_in_flight_msat: 0,
max_channel_reserve_satoshis: <u64>::max_value(),
min_max_accepted_htlcs: 0,
max_minimum_depth: 144,
force_announced_channel_preference: true,
their_to_self_delay: MAX_LOCAL_BREAKDOWN_TIMEOUT,
}
}
}
#[derive(Copy, Clone, Debug)]
pub struct ChannelConfig {
pub forwarding_fee_proportional_millionths: u32,
pub forwarding_fee_base_msat: u32,
pub cltv_expiry_delta: u16,
pub announced_channel: bool,
pub commit_upfront_shutdown_pubkey: bool,
pub max_dust_htlc_exposure_msat: u64,
pub force_close_avoidance_max_fee_satoshis: u64,
}
impl Default for ChannelConfig {
fn default() -> Self {
ChannelConfig {
forwarding_fee_proportional_millionths: 0,
forwarding_fee_base_msat: 1000,
cltv_expiry_delta: 6 * 12, announced_channel: false,
commit_upfront_shutdown_pubkey: true,
max_dust_htlc_exposure_msat: 5_000_000,
force_close_avoidance_max_fee_satoshis: 1000,
}
}
}
impl_writeable_tlv_based!(ChannelConfig, {
(0, forwarding_fee_proportional_millionths, required),
(1, max_dust_htlc_exposure_msat, (default_value, 5_000_000)),
(2, cltv_expiry_delta, required),
(3, force_close_avoidance_max_fee_satoshis, (default_value, 1000)),
(4, announced_channel, required),
(6, commit_upfront_shutdown_pubkey, required),
(8, forwarding_fee_base_msat, required),
});
#[derive(Copy, Clone, Debug)]
pub struct UserConfig {
pub own_channel_config: ChannelHandshakeConfig,
pub peer_channel_config_limits: ChannelHandshakeLimits,
pub channel_options: ChannelConfig,
pub accept_forwards_to_priv_channels: bool,
}
impl Default for UserConfig {
fn default() -> Self {
UserConfig {
own_channel_config: ChannelHandshakeConfig::default(),
peer_channel_config_limits: ChannelHandshakeLimits::default(),
channel_options: ChannelConfig::default(),
accept_forwards_to_priv_channels: false,
}
}
}