lightningd: control onion messages by experimental-onion-messages option.

Note that this also changes so the feature is not represented in channels,
reflecting the recent drafts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: `experimental-onion-messages` enables send, receive and relay of onion messages.
This commit is contained in:
Rusty Russell
2021-01-13 13:30:20 +10:30
committed by Christian Decker
parent 5a483ddd8b
commit fc3e679c97
8 changed files with 34 additions and 30 deletions

View File

@@ -799,6 +799,14 @@ static char *opt_set_dual_fund(struct lightningd *ld)
return NULL;
}
static char *opt_set_onion_messages(struct lightningd *ld)
{
feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL,
OPTIONAL_FEATURE(OPT_ONION_MESSAGES))));
return NULL;
}
static void register_opts(struct lightningd *ld)
{
/* This happens before plugins started */
@@ -846,6 +854,11 @@ static void register_opts(struct lightningd *ld)
" and allow peers to establish channels"
" via v2 channel open protocol");
/* This affects our features, so set early. */
opt_register_early_noarg("--experimental-onion-messages",
opt_set_onion_messages, ld,
"EXPERIMENTAL: enable send, receive and relay"
" of onion messages");
opt_register_noarg("--help|-h", opt_lightningd_usage, ld,
"Print this message.");
@@ -1262,6 +1275,11 @@ static void add_config(struct lightningd *ld,
feature_offered(ld->our_features
->bits[INIT_FEATURE],
OPT_DUAL_FUND));
} else if (opt->cb == (void *)opt_set_onion_messages) {
json_add_bool(response, name0,
feature_offered(ld->our_features
->bits[INIT_FEATURE],
OPT_ONION_MESSAGES));
} else if (opt->cb == (void *)plugin_opt_flag_set) {
/* Noop, they will get added below along with the
* OPT_HASARG options. */