Skip to content

Commit c99c951

Browse files
committed
Add SimpleClose feature for bits 60/61
We define the feature bits that will be set in `Init` and `Node` contexts.
1 parent 09f57a9 commit c99c951

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

lightning-types/src/features.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown`
5151
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information).
5252
//! - `DualFund` - requires/supports V2 channel establishment
53-
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#channel-establishment-v2) for more information).
53+
//! - `SimpleClose` - requires/supports simplified closing negotiation
54+
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_complete-and-closing_sig) for more information).
5455
//! - `OnionMessages` - requires/supports forwarding onion messages
5556
//! (see [BOLT-7](https://github.com/lightning/bolts/pull/759/files) for more information).
5657
// TODO: update link
@@ -161,7 +162,7 @@ mod sealed {
161162
// Byte 6
162163
ZeroConf,
163164
// Byte 7
164-
Trampoline,
165+
Trampoline | SimpleClose,
165166
]
166167
);
167168
define_context!(
@@ -182,7 +183,7 @@ mod sealed {
182183
// Byte 6
183184
ZeroConf | Keysend,
184185
// Byte 7
185-
Trampoline,
186+
Trampoline | SimpleClose,
186187
// Byte 8 - 31
187188
,,,,,,,,,,,,,,,,,,,,,,,,
188189
// Byte 32
@@ -663,6 +664,17 @@ mod sealed {
663664
// By default, allocate enough bytes to cover up to Trampoline. Update this as new features are
664665
// added which we expect to appear commonly across contexts.
665666
pub(super) const MIN_FEATURES_ALLOCATION_BYTES: usize = (57 + 7) / 8;
667+
define_feature!(
668+
61,
669+
SimpleClose,
670+
[InitContext, NodeContext],
671+
"Feature flags for simplified closing negotiation.",
672+
set_simple_close_optional,
673+
set_simple_close_required,
674+
clear_simple_close,
675+
supports_simple_close,
676+
requires_simple_close
677+
);
666678
define_feature!(
667679
259,
668680
DnsResolver,
@@ -1355,6 +1367,7 @@ mod tests {
13551367
init_features.set_scid_privacy_optional();
13561368
init_features.set_zero_conf_optional();
13571369
init_features.set_quiescence_optional();
1370+
init_features.set_simple_close_optional();
13581371

13591372
assert!(init_features.initial_routing_sync());
13601373
assert!(!init_features.supports_upfront_shutdown_script());
@@ -1370,14 +1383,16 @@ mod tests {
13701383
// - onion_messages
13711384
// - option_channel_type | option_scid_alias
13721385
// - option_zeroconf
1373-
assert_eq!(node_features.flags.len(), 7);
1386+
// - option_simple_close
1387+
assert_eq!(node_features.flags.len(), 8);
13741388
assert_eq!(node_features.flags[0], 0b00000001);
13751389
assert_eq!(node_features.flags[1], 0b01010001);
13761390
assert_eq!(node_features.flags[2], 0b10001010);
13771391
assert_eq!(node_features.flags[3], 0b00001010);
13781392
assert_eq!(node_features.flags[4], 0b10001000);
13791393
assert_eq!(node_features.flags[5], 0b10100000);
13801394
assert_eq!(node_features.flags[6], 0b00001000);
1395+
assert_eq!(node_features.flags[7], 0b00100000);
13811396
}
13821397

13831398
// Check that cleared flags are kept blank when converting back:

0 commit comments

Comments
 (0)