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
if !matches!(self.context.channel_state, ChannelState::NegotiatingFunding(flags) if flags == NegotiatingFundingFlags::OUR_INIT_SENT) {
6655
6655
return Err(ChannelError::Close("Got an accept_channel message at a strange time".to_owned()));
6656
6656
}
6657
-
if msg.dust_limit_satoshis > 21000000 * 100000000 {
6658
-
return Err(ChannelError::Close(format!("Peer never wants payout outputs? dust_limit_satoshis was {}", msg.dust_limit_satoshis)));
6657
+
if msg.common_fields.dust_limit_satoshis > 21000000 * 100000000 {
6658
+
return Err(ChannelError::Close(format!("Peer never wants payout outputs? dust_limit_satoshis was {}", msg.common_fields.dust_limit_satoshis)));
6659
6659
}
6660
6660
if msg.channel_reserve_satoshis > self.context.channel_value_satoshis {
6661
6661
return Err(ChannelError::Close(format!("Bogus channel_reserve_satoshis ({}). Must not be greater than ({})", msg.channel_reserve_satoshis, self.context.channel_value_satoshis)));
6662
6662
}
6663
-
if msg.dust_limit_satoshis > self.context.holder_selected_channel_reserve_satoshis {
6664
-
return Err(ChannelError::Close(format!("Dust limit ({}) is bigger than our channel reserve ({})", msg.dust_limit_satoshis, self.context.holder_selected_channel_reserve_satoshis)));
6663
+
if msg.common_fields.dust_limit_satoshis > self.context.holder_selected_channel_reserve_satoshis {
6664
+
return Err(ChannelError::Close(format!("Dust limit ({}) is bigger than our channel reserve ({})", msg.common_fields.dust_limit_satoshis, self.context.holder_selected_channel_reserve_satoshis)));
6665
6665
}
6666
6666
if msg.channel_reserve_satoshis > self.context.channel_value_satoshis - self.context.holder_selected_channel_reserve_satoshis {
6667
6667
return Err(ChannelError::Close(format!("Bogus channel_reserve_satoshis ({}). Must not be greater than channel value minus our reserve ({})",
let full_channel_value_msat = (self.context.channel_value_satoshis - msg.channel_reserve_satoshis) * 1000;
6671
-
if msg.htlc_minimum_msat >= full_channel_value_msat {
6672
-
return Err(ChannelError::Close(format!("Minimum htlc value ({}) is full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));
6671
+
if msg.common_fields.htlc_minimum_msat >= full_channel_value_msat {
6672
+
return Err(ChannelError::Close(format!("Minimum htlc value ({}) is full channel value ({})", msg.common_fields.htlc_minimum_msat, full_channel_value_msat)));
6673
6673
}
6674
6674
let max_delay_acceptable = u16::min(peer_limits.their_to_self_delay, MAX_LOCAL_BREAKDOWN_TIMEOUT);
6675
-
if msg.to_self_delay > max_delay_acceptable {
6676
-
return Err(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)));
6675
+
if msg.common_fields.to_self_delay > max_delay_acceptable {
6676
+
return Err(ChannelError::Close(format!("They wanted our payments to be delayed by a needlessly long period. Upper limit: {}. Actual: {}", max_delay_acceptable, msg.common_fields.to_self_delay)));
6677
6677
}
6678
-
if msg.max_accepted_htlcs < 1 {
6678
+
if msg.common_fields.max_accepted_htlcs < 1 {
6679
6679
return Err(ChannelError::Close("0 max_accepted_htlcs makes for a useless channel".to_owned()));
6680
6680
}
6681
-
if msg.max_accepted_htlcs > MAX_HTLCS {
6682
-
return Err(ChannelError::Close(format!("max_accepted_htlcs was {}. It must not be larger than {}", msg.max_accepted_htlcs, MAX_HTLCS)));
6681
+
if msg.common_fields.max_accepted_htlcs > MAX_HTLCS {
6682
+
return Err(ChannelError::Close(format!("max_accepted_htlcs was {}. It must not be larger than {}", msg.common_fields.max_accepted_htlcs, MAX_HTLCS)));
6683
6683
}
6684
6684
6685
6685
// Now check against optional parameters as set by config...
6686
-
if msg.htlc_minimum_msat > peer_limits.max_htlc_minimum_msat {
6687
-
return Err(ChannelError::Close(format!("htlc_minimum_msat ({}) is higher than the user specified limit ({})", msg.htlc_minimum_msat, peer_limits.max_htlc_minimum_msat)));
6686
+
if msg.common_fields.htlc_minimum_msat > peer_limits.max_htlc_minimum_msat {
6687
+
return Err(ChannelError::Close(format!("htlc_minimum_msat ({}) is higher than the user specified limit ({})", msg.common_fields.htlc_minimum_msat, peer_limits.max_htlc_minimum_msat)));
6688
6688
}
6689
-
if msg.max_htlc_value_in_flight_msat < peer_limits.min_max_htlc_value_in_flight_msat {
6690
-
return Err(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)));
6689
+
if msg.common_fields.max_htlc_value_in_flight_msat < peer_limits.min_max_htlc_value_in_flight_msat {
6690
+
return Err(ChannelError::Close(format!("max_htlc_value_in_flight_msat ({}) is less than the user specified limit ({})", msg.common_fields.max_htlc_value_in_flight_msat, peer_limits.min_max_htlc_value_in_flight_msat)));
6691
6691
}
6692
6692
if msg.channel_reserve_satoshis > peer_limits.max_channel_reserve_satoshis {
6693
6693
return Err(ChannelError::Close(format!("channel_reserve_satoshis ({}) is higher than the user specified limit ({})", msg.channel_reserve_satoshis, peer_limits.max_channel_reserve_satoshis)));
6694
6694
}
6695
-
if msg.max_accepted_htlcs < peer_limits.min_max_accepted_htlcs {
6696
-
return Err(ChannelError::Close(format!("max_accepted_htlcs ({}) is less than the user specified limit ({})", msg.max_accepted_htlcs, peer_limits.min_max_accepted_htlcs)));
6695
+
if msg.common_fields.max_accepted_htlcs < peer_limits.min_max_accepted_htlcs {
6696
+
return Err(ChannelError::Close(format!("max_accepted_htlcs ({}) is less than the user specified limit ({})", msg.common_fields.max_accepted_htlcs, peer_limits.min_max_accepted_htlcs)));
6697
6697
}
6698
-
if msg.dust_limit_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS {
6699
-
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the implementation limit ({})", msg.dust_limit_satoshis, MIN_CHAN_DUST_LIMIT_SATOSHIS)));
6698
+
if msg.common_fields.dust_limit_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS {
6699
+
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the implementation limit ({})", msg.common_fields.dust_limit_satoshis, MIN_CHAN_DUST_LIMIT_SATOSHIS)));
6700
6700
}
6701
-
if msg.dust_limit_satoshis > MAX_CHAN_DUST_LIMIT_SATOSHIS {
6702
-
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is greater than the implementation limit ({})", msg.dust_limit_satoshis, MAX_CHAN_DUST_LIMIT_SATOSHIS)));
6701
+
if msg.common_fields.dust_limit_satoshis > MAX_CHAN_DUST_LIMIT_SATOSHIS {
6702
+
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is greater than the implementation limit ({})", msg.common_fields.dust_limit_satoshis, MAX_CHAN_DUST_LIMIT_SATOSHIS)));
6703
6703
}
6704
-
if msg.minimum_depth > peer_limits.max_minimum_depth {
6705
-
return Err(ChannelError::Close(format!("We consider the minimum depth to be unreasonably large. Expected minimum: ({}). Actual: ({})", peer_limits.max_minimum_depth, msg.minimum_depth)));
6704
+
if msg.common_fields.minimum_depth > peer_limits.max_minimum_depth {
6705
+
return Err(ChannelError::Close(format!("We consider the minimum depth to be unreasonably large. Expected minimum: ({}). Actual: ({})", peer_limits.max_minimum_depth, msg.common_fields.minimum_depth)));
6706
6706
}
6707
6707
6708
-
if let Some(ty) = &msg.channel_type {
6708
+
if let Some(ty) = &msg.common_fields.channel_type {
6709
6709
if *ty != self.context.channel_type {
6710
6710
return Err(ChannelError::Close("Channel Type in accept_channel didn't match the one sent in open_channel.".to_owned()));
return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got an unexpected accept_channel message from peer with counterparty_node_id {}", counterparty_node_id), msg.temporary_channel_id));
6314
+
return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got an unexpected accept_channel message from peer with counterparty_node_id {}", counterparty_node_id), msg.common_fields.temporary_channel_id));
6315
6315
}
6316
6316
}
6317
6317
},
6318
-
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.temporary_channel_id))
6318
+
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.common_fields.temporary_channel_id))
6319
6319
}
6320
6320
};
6321
6321
let mut pending_events = self.pending_events.lock().unwrap();
0 commit comments