Skip to content

Commit 7f8bab5

Browse files
committed
Fix allowed channel types.
1 parent 3f850c8 commit 7f8bab5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lightning/src/ln/channel.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,11 +1081,19 @@ impl<Signer: Sign> Channel<Signer> {
10811081
if channel_type.supports_any_optional_bits() {
10821082
return Err(ChannelError::Close("Channel Type field contained optional bits - this is not allowed".to_owned()));
10831083
}
1084-
// We currently only allow two channel types, so write it all out here - we allow
1084+
// We currently only allow three channel types, so write it all out here - we allow
10851085
// `only_static_remote_key` in all contexts, and further allow
1086-
// `static_remote_key|scid_privacy` if the channel is not publicly announced.
1086+
// `static_remote_key | scid_privacy` or `static_remote_key | zero_conf`, if the channel
1087+
// is not publicly announced.
10871088
if *channel_type != ChannelTypeFeatures::only_static_remote_key() {
1088-
if !channel_type.requires_scid_privacy() && !channel_type.requires_zero_conf() {
1089+
let mut static_remote_key_with_privacy_type = ChannelTypeFeatures::only_static_remote_key();
1090+
static_remote_key_with_privacy_type.set_scid_privacy_required();
1091+
1092+
let mut static_remote_key_with_zero_conf_type = ChannelTypeFeatures::only_static_remote_key();
1093+
static_remote_key_with_zero_conf_type.set_zero_conf_required();
1094+
1095+
if *channel_type != static_remote_key_with_privacy_type &&
1096+
*channel_type != static_remote_key_with_zero_conf_type {
10891097
return Err(ChannelError::Close("Channel Type was not understood".to_owned()));
10901098
}
10911099
if announced_channel {
@@ -7730,13 +7738,10 @@ mod tests {
77307738
let keys_provider = test_utils::TestKeysInterface::new(&seed, network);
77317739
let logger = test_utils::TestLogger::new();
77327740

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

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

0 commit comments

Comments
 (0)