bolt: Reflect the zeroconf featurebits in code

This commit is contained in:
Christian Decker 2022-04-14 14:35:39 +02:00
parent 185cd81be4
commit e4511452ac
5 changed files with 51 additions and 4 deletions

View file

@ -89,6 +89,26 @@ static const struct feature_style feature_styles[] = {
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
/* FIXME: Currently not explicitly signalled, but we do
* support it for zeroconf */
{ OPT_SCID_ALIAS,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_DONT_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
/* Zeroconf is always signalled in `init`, but we still
* negotiate on a per-channel basis when calling `fundchannel`
* with the `mindepth` parameter, and accept a channel with
* the `open_channel` hook and its return value for
* `mindepth`.
*/
{ OPT_ZEROCONF,
.copy_style = {
[INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_DONT_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
{ OPT_SHUTDOWN_ANYSEGWIT,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
@ -422,9 +442,9 @@ const char *feature_name(const tal_t *ctx, size_t f)
"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,
NULL,
"option_scid_alias", /* https://github.com/lightning/bolts/pull/910 */
"option_payment_metadata",
NULL, /* 50/51 */
"option_zeroconf", /* 50/51, https://github.com/lightning/bolts/pull/910 */
NULL,
"option_keysend",
NULL,
@ -546,3 +566,14 @@ const char *fmt_featurebits(const tal_t *ctx, const u8 *featurebits)
}
return fmt;
}
struct feature_set *feature_set_dup(const tal_t *ctx,
const struct feature_set *other)
{
struct feature_set *res = tal(ctx, struct feature_set);
for (size_t i = 0; i < ARRAY_SIZE(res->bits); i++)
res->bits[i] = tal_dup_talarr(res, u8, other->bits[i]);
return res;
}

View file

@ -81,6 +81,9 @@ bool featurebits_eq(const u8 *f1, const u8 *f2);
/* Good for debugging: returns comma-separated string of bits. */
const char *fmt_featurebits(const tal_t *ctx, const u8 *featurebits);
struct feature_set *feature_set_dup(const tal_t *ctx,
const struct feature_set *other);
/* BOLT #9:
*
* Flags are numbered from the least-significant bit, at bit 0 (i.e. 0x1,
@ -134,6 +137,13 @@ const char *fmt_featurebits(const tal_t *ctx, const u8 *featurebits);
*/
#define OPT_DUAL_FUND 28
/* BOLT-519be05f61e2c35ddf95b731203f89b4ee0946c3 #9:
* | 46/47 | `option_scid_alias` | ... IN ...
* | 50/51 | `option_eroconf` | ... IN ...
*/
#define OPT_SCID_ALIAS 46
#define OPT_ZEROCONF 50
/* BOLT-quiescent #9:
* | 34/35 | `option_quiesce` | ... IN ...
*/

View file

@ -824,6 +824,8 @@ static struct feature_set *default_features(const tal_t *ctx)
OPTIONAL_FEATURE(OPT_STATIC_REMOTEKEY),
OPTIONAL_FEATURE(OPT_SHUTDOWN_ANYSEGWIT),
OPTIONAL_FEATURE(OPT_PAYMENT_METADATA),
OPTIONAL_FEATURE(OPT_SCID_ALIAS),
OPTIONAL_FEATURE(OPT_ZEROCONF),
#if EXPERIMENTAL_FEATURES
OPTIONAL_FEATURE(OPT_ANCHOR_OUTPUTS),
OPTIONAL_FEATURE(OPT_QUIESCE),

View file

@ -1819,9 +1819,13 @@ def test_list_features_only(node_factory):
expected += ['option_shutdown_anysegwit/odd']
expected += ['option_quiesce/odd']
expected += ['option_onion_messages/odd']
expected += ['option_scid_alias/odd']
expected += ['option_zeroconf/odd']
expected += ['supports_open_accept_channel_type']
else:
expected += ['option_shutdown_anysegwit/odd']
expected += ['option_scid_alias/odd']
expected += ['option_zeroconf/odd']
assert features == expected

View file

@ -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]
features = [1, 5, 7, 8, 11, 13, 14, 17, 27, 47, 51]
if EXPERIMENTAL_FEATURES:
# OPT_ONION_MESSAGES
features += [39]
@ -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, 55]
features = [1, 5, 7, 8, 11, 13, 14, 17, 27, 47, 51, 55]
if EXPERIMENTAL_FEATURES:
# OPT_ONION_MESSAGES
features += [39]