Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature neatening #5455

Merged
merged 2 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion common/features.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ static const struct feature_style feature_styles[] = {
* we refuse to parse it. */
[BOLT11_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT } },
{ OPT_CHANNEL_TYPE,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_DONT_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT } },
};

struct dependency {
Expand Down Expand Up @@ -441,7 +446,7 @@ const char *feature_name(const tal_t *ctx, size_t f)
"option_onion_messages", /* https://github.com/lightningnetwork/lightning-rfc/pull/759 */
"option_want_peer_backup", /* 40/41 */ /* https://github.com/lightningnetwork/lightning-rfc/pull/881 */
"option_provide_peer_backup", /* https://github.com/lightningnetwork/lightning-rfc/pull/881 */
NULL,
"option_channel_type",
"option_scid_alias", /* https://github.com/lightning/bolts/pull/910 */
"option_payment_metadata",
"option_zeroconf", /* 50/51, https://github.com/lightning/bolts/pull/910 */
Expand Down
36 changes: 17 additions & 19 deletions common/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,22 @@ struct feature_set *feature_set_dup(const tal_t *ctx,

/* BOLT #9:
*
* | Bits | Name |...
* | 0/1 | `option_data_loss_protect` |...
* | 3 | `initial_routing_sync` |...
* | 4/5 | `option_upfront_shutdown_script` |...
* | 6/7 | `gossip_queries` |...
* | 8/9 | `var_onion_optin` |...
* | 10/11 | `gossip_queries_ex` |...
* | 12/13 | `option_static_remotekey` |...
* | Bits | Name |...
* | 0/1 | `option_data_loss_protect` |... IN ...
* | 3 | `initial_routing_sync` |... I ...
* | 4/5 | `option_upfront_shutdown_script` |... IN ...
* | 6/7 | `gossip_queries` |... IN ...
* | 8/9 | `var_onion_optin` |... IN9 ...
* | 10/11 | `gossip_queries_ex` |... IN ...
* | 12/13 | `option_static_remotekey` |... IN ...
* | 14/15 | `payment_secret` |... IN9 ...
* | 16/17 | `basic_mpp` |... IN9 ...
* | 18/19 | `option_support_large_channel` |... IN ...
* | 20/21 | `option_anchor_outputs` |... IN ...
* | 22/23 | `option_anchors_zero_fee_htlc_tx` |... IN ...
* | 26/27 | `option_shutdown_anysegwit` |... IN ...
* | 44/45 | `option_channel_type` |... IN ...
* | 48/49 | `option_payment_metadata` |... 9 ...
*/
#define OPT_DATA_LOSS_PROTECT 0
#define OPT_INITIAL_ROUTING_SYNC 2
Expand All @@ -115,23 +123,13 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
#define OPT_VAR_ONION 8
#define OPT_GOSSIP_QUERIES_EX 10
#define OPT_STATIC_REMOTEKEY 12

/* BOLT #9:
*
* | 14/15 | `payment_secret` |... IN9 ...
* | 16/17 | `basic_mpp` |... IN9 ...
* | 18/19 | `option_support_large_channel` |... IN ...
* | 20/21 | `option_anchor_outputs` |... IN ...
* | 22/23 | `option_anchors_zero_fee_htlc_tx` |... IN ...
* | 26/27 | `option_shutdown_anysegwit` |... IN ...
* | 48/49 | `option_payment_metadata` |... 9 ...
*/
#define OPT_PAYMENT_SECRET 14
#define OPT_BASIC_MPP 16
#define OPT_LARGE_CHANNELS 18
#define OPT_ANCHOR_OUTPUTS 20
#define OPT_ANCHORS_ZERO_FEE_HTLC_TX 22
#define OPT_SHUTDOWN_ANYSEGWIT 26
#define OPT_CHANNEL_TYPE 44
#define OPT_PAYMENT_METADATA 48

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #9:
Expand Down
1 change: 1 addition & 0 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ static struct feature_set *default_features(const tal_t *ctx)
OPTIONAL_FEATURE(OPT_PAYMENT_METADATA),
OPTIONAL_FEATURE(OPT_SCID_ALIAS),
OPTIONAL_FEATURE(OPT_ZEROCONF),
OPTIONAL_FEATURE(OPT_CHANNEL_TYPE),
#if EXPERIMENTAL_FEATURES
OPTIONAL_FEATURE(OPT_ANCHOR_OUTPUTS),
OPTIONAL_FEATURE(OPT_QUIESCE),
Expand Down
2 changes: 2 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1826,11 +1826,13 @@ def test_list_features_only(node_factory):
expected += ['option_shutdown_anysegwit/odd']
expected += ['option_quiesce/odd']
expected += ['option_onion_messages/odd']
expected += ['option_channel_type/odd']
expected += ['option_scid_alias/odd']
expected += ['option_zeroconf/odd']
expected += ['supports_open_accept_channel_type']
else:
expected += ['option_shutdown_anysegwit/odd']
expected += ['option_channel_type/odd']
expected += ['option_scid_alias/odd']
expected += ['option_zeroconf/odd']
assert features == expected
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def hex_bits(features):

def expected_peer_features(wumbo_channels=False, extra=[]):
"""Return the expected peer features hexstring for this configuration"""
features = [1, 5, 7, 8, 11, 13, 14, 17, 27, 47, 51]
features = [1, 5, 7, 8, 11, 13, 14, 17, 27, 45, 47, 51]
if EXPERIMENTAL_FEATURES:
# OPT_ONION_MESSAGES
features += [39]
Expand All @@ -59,7 +59,7 @@ def expected_peer_features(wumbo_channels=False, extra=[]):
# features for the 'node' and the 'peer' feature sets
def expected_node_features(wumbo_channels=False, extra=[]):
"""Return the expected node features hexstring for this configuration"""
features = [1, 5, 7, 8, 11, 13, 14, 17, 27, 47, 51, 55]
features = [1, 5, 7, 8, 11, 13, 14, 17, 27, 45, 47, 51, 55]
if EXPERIMENTAL_FEATURES:
# OPT_ONION_MESSAGES
features += [39]
Expand Down