You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Store override counterparty handshake limits until we enforce them
We currently allow users to provide an `override_config` in
`ChannelManager::create_channel` which it seems should apply to the
channel. However, because we don't store any of it, the only parts
which we apply to the channel are those which are set in the
`Channel` object immediately in `Channel::new_outbound` and used
from there.
This is great in most cases, however the
`UserConfig::peer_channel_config_limits` `ChannelHandshakeLimits`
object is used in `accept_channel` to bound what is acceptable in
our peer's `AcceptChannel` message. Thus, for outbound channels, we
are given a full `UserConfig` object to "override" the default
config, but we don't use any of the handshake limits specified in
it.
Here, we move to storing the `ChannelHandshakeLimits` explicitly
and applying it when we receive our peer's `AcceptChannel`. Note
that we don't need to store it anywhere because if we haven't
received an `AcceptChannel` from our peer when we reload from disk
we will forget the channel entirely anyway.
if msg.htlc_minimum_msat >= full_channel_value_msat {
1833
1839
returnErr(ChannelError::Close(format!("Minimum htlc value ({}) is full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));
1834
1840
}
1835
-
let max_delay_acceptable = u16::min(config.peer_channel_config_limits.their_to_self_delay,MAX_LOCAL_BREAKDOWN_TIMEOUT);
1841
+
let max_delay_acceptable = u16::min(peer_limits.their_to_self_delay,MAX_LOCAL_BREAKDOWN_TIMEOUT);
1836
1842
if msg.to_self_delay > max_delay_acceptable {
1837
1843
returnErr(ChannelError::Close(format!("They wanted our payments to be delayed by a needlessly long period. Upper limit: {}. Actual: {}", max_delay_acceptable, msg.to_self_delay)));
// Now check against optional parameters as set by config...
1847
-
if msg.htlc_minimum_msat > config.peer_channel_config_limits.max_htlc_minimum_msat{
1848
-
returnErr(ChannelError::Close(format!("htlc_minimum_msat ({}) is higher than the user specified limit ({})", msg.htlc_minimum_msat,config.peer_channel_config_limits.max_htlc_minimum_msat)));
1853
+
if msg.htlc_minimum_msat > peer_limits.max_htlc_minimum_msat{
1854
+
returnErr(ChannelError::Close(format!("htlc_minimum_msat ({}) is higher than the user specified limit ({})", msg.htlc_minimum_msat,peer_limits.max_htlc_minimum_msat)));
1849
1855
}
1850
-
if msg.max_htlc_value_in_flight_msat < config.peer_channel_config_limits.min_max_htlc_value_in_flight_msat{
1851
-
returnErr(ChannelError::Close(format!("max_htlc_value_in_flight_msat ({}) is less than the user specified limit ({})", msg.max_htlc_value_in_flight_msat,config.peer_channel_config_limits.min_max_htlc_value_in_flight_msat)));
1856
+
if msg.max_htlc_value_in_flight_msat < peer_limits.min_max_htlc_value_in_flight_msat{
1857
+
returnErr(ChannelError::Close(format!("max_htlc_value_in_flight_msat ({}) is less than the user specified limit ({})", msg.max_htlc_value_in_flight_msat,peer_limits.min_max_htlc_value_in_flight_msat)));
1852
1858
}
1853
-
if msg.channel_reserve_satoshis > config.peer_channel_config_limits.max_channel_reserve_satoshis{
1854
-
returnErr(ChannelError::Close(format!("channel_reserve_satoshis ({}) is higher than the user specified limit ({})", msg.channel_reserve_satoshis,config.peer_channel_config_limits.max_channel_reserve_satoshis)));
1859
+
if msg.channel_reserve_satoshis > peer_limits.max_channel_reserve_satoshis{
1860
+
returnErr(ChannelError::Close(format!("channel_reserve_satoshis ({}) is higher than the user specified limit ({})", msg.channel_reserve_satoshis,peer_limits.max_channel_reserve_satoshis)));
1855
1861
}
1856
-
if msg.max_accepted_htlcs < config.peer_channel_config_limits.min_max_accepted_htlcs{
1857
-
returnErr(ChannelError::Close(format!("max_accepted_htlcs ({}) is less than the user specified limit ({})", msg.max_accepted_htlcs,config.peer_channel_config_limits.min_max_accepted_htlcs)));
1862
+
if msg.max_accepted_htlcs < peer_limits.min_max_accepted_htlcs{
1863
+
returnErr(ChannelError::Close(format!("max_accepted_htlcs ({}) is less than the user specified limit ({})", msg.max_accepted_htlcs,peer_limits.min_max_accepted_htlcs)));
1858
1864
}
1859
1865
if msg.dust_limit_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS{
1860
1866
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the implementation limit ({})", msg.dust_limit_satoshis,MIN_CHAN_DUST_LIMIT_SATOSHIS)));
1861
1867
}
1862
1868
if msg.dust_limit_satoshis > MAX_CHAN_DUST_LIMIT_SATOSHIS{
1863
1869
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is greater than the implementation limit ({})", msg.dust_limit_satoshis,MAX_CHAN_DUST_LIMIT_SATOSHIS)));
1864
1870
}
1865
-
if msg.minimum_depth > config.peer_channel_config_limits.max_minimum_depth{
1866
-
returnErr(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)));
1871
+
if msg.minimum_depth > peer_limits.max_minimum_depth{
1872
+
returnErr(ChannelError::Close(format!("We consider the minimum depth to be unreasonably large. Expected minimum: ({}). Actual: ({})",peer_limits.max_minimum_depth, msg.minimum_depth)));
1867
1873
}
1868
1874
if msg.minimum_depth == 0{
1869
1875
// Note that if this changes we should update the serialization minimum version to
0 commit comments