Skip to content

Commit a3ddb9f

Browse files
committed
Avoid treating option_upfront_shutdown (req) as unknown_required.
This fixes the bitmask in requires_unknown_bits.
1 parent 2514530 commit a3ddb9f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lightning/src/ln/features.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,14 @@ impl<T: sealed::Context> Features<T> {
187187
pub(crate) fn requires_unknown_bits(&self) -> bool {
188188
self.flags.iter().enumerate().any(|(idx, &byte)| {
189189
(match idx {
190-
0 => (byte & 0b00010100),
190+
// Unknown bits are even bits which we don't understand, we list ones which we do
191+
// here:
192+
// unknown, upfront_shutdown_script, unknown (actually initial_routing_sync, but it
193+
// is only valid as an optional feature), and data_loss_protect:
194+
0 => (byte & 0b01000100),
195+
// unknown, unknown, unknown, var_onion_optin:
191196
1 => (byte & 0b01010100),
197+
// fallback, all even bits set:
192198
_ => (byte & 0b01010101),
193199
}) != 0
194200
})
@@ -197,7 +203,10 @@ impl<T: sealed::Context> Features<T> {
197203
pub(crate) fn supports_unknown_bits(&self) -> bool {
198204
self.flags.iter().enumerate().any(|(idx, &byte)| {
199205
(match idx {
206+
// unknown, upfront_shutdown_script, initial_routing_sync (is only valid as an
207+
// optional feature), and data_loss_protect:
200208
0 => (byte & 0b11000100),
209+
// unknown, unknown, unknown, var_onion_optin:
201210
1 => (byte & 0b11111100),
202211
_ => byte,
203212
}) != 0

0 commit comments

Comments
 (0)