options: create enable/disable option for peer storage.

Since it's not spec-final yet (hell, it's not even properly specified
yet!) we need to put it behind an experimental flag.

Unfortunately, we don't have support for doing this in a plugin; a
plugin must present features before parsing options.  So we need to do
it in core.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-02-05 14:14:00 +10:30
committed by Alex Myers
parent c60ea5bcbb
commit a71bd3ea37
6 changed files with 57 additions and 15 deletions

View File

@@ -1078,6 +1078,15 @@ static char *opt_set_shutdown_wrong_funding(struct lightningd *ld)
return NULL;
}
static char *opt_set_peer_storage(struct lightningd *ld)
{
feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL, OPT_PROVIDE_PEER_BACKUP_STORAGE)));
feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL, OPT_WANT_PEER_BACKUP_STORAGE)));
return NULL;
}
static char *opt_set_offers(struct lightningd *ld)
{
ld->config.exp_offers = true;
@@ -1156,6 +1165,9 @@ static void register_opts(struct lightningd *ld)
opt_register_early_noarg("--experimental-shutdown-wrong-funding",
opt_set_shutdown_wrong_funding, ld,
"EXPERIMENTAL: allow shutdown with alternate txids");
opt_register_early_noarg("--experimental-peer-storage",
opt_set_peer_storage, ld,
"EXPERIMENTAL: enable peer backup storage and restore");
opt_register_early_arg("--announce-addr-dns",
opt_set_bool_arg, opt_show_bool,
&ld->announce_dns,
@@ -1641,6 +1653,11 @@ static void add_config(struct lightningd *ld,
feature_offered(ld->our_features
->bits[INIT_FEATURE],
OPT_SHUTDOWN_WRONG_FUNDING));
} else if (opt->cb == (void *)opt_set_peer_storage) {
json_add_bool(response, name0,
feature_offered(ld->our_features
->bits[INIT_FEATURE],
OPT_PROVIDE_PEER_BACKUP_STORAGE));
} else if (opt->cb == (void *)plugin_opt_flag_set) {
/* Noop, they will get added below along with the
* OPT_HASARG options. */