Skip to content

Commit

Permalink
Fix allowed channel types.
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed May 31, 2022
1 parent 3f850c8 commit 7f8bab5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,11 +1081,19 @@ impl<Signer: Sign> Channel<Signer> {
if channel_type.supports_any_optional_bits() {
return Err(ChannelError::Close("Channel Type field contained optional bits - this is not allowed".to_owned()));
}
// We currently only allow two channel types, so write it all out here - we allow
// We currently only allow three channel types, so write it all out here - we allow
// `only_static_remote_key` in all contexts, and further allow
// `static_remote_key|scid_privacy` if the channel is not publicly announced.
// `static_remote_key | scid_privacy` or `static_remote_key | zero_conf`, if the channel
// is not publicly announced.
if *channel_type != ChannelTypeFeatures::only_static_remote_key() {
if !channel_type.requires_scid_privacy() && !channel_type.requires_zero_conf() {
let mut static_remote_key_with_privacy_type = ChannelTypeFeatures::only_static_remote_key();
static_remote_key_with_privacy_type.set_scid_privacy_required();

let mut static_remote_key_with_zero_conf_type = ChannelTypeFeatures::only_static_remote_key();
static_remote_key_with_zero_conf_type.set_zero_conf_required();

if *channel_type != static_remote_key_with_privacy_type &&
*channel_type != static_remote_key_with_zero_conf_type {
return Err(ChannelError::Close("Channel Type was not understood".to_owned()));
}
if announced_channel {
Expand Down Expand Up @@ -7730,13 +7738,10 @@ mod tests {
let keys_provider = test_utils::TestKeysInterface::new(&seed, network);
let logger = test_utils::TestLogger::new();

// Create Node A's channel pointing to Node B's pubkey
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
let config = UserConfig::default();
let node_a_chan = Channel::<EnforcingSigner>::new_outbound(&&feeest, &&keys_provider, node_b_node_id, &InitFeatures::known(), 10000000, 100000, 42, &config, 0, 42).unwrap();

// Create Node B's channel by receiving Node A's open_channel message
// Make sure A's dust limit is as we expect.
let mut channel_type_features = ChannelTypeFeatures::only_static_remote_key();
channel_type_features.set_zero_conf_required();

Expand Down

0 comments on commit 7f8bab5

Please sign in to comment.