experimental-dual-fund: add config level option for enabling dual-fund

Allow a user to switch on dual-funding without needing to compile
as EXPERIMENTAL_FEATURES.

Doesn't work yet, since everything is still behind
'EXPERIMENTAL_FEATURES' compile time flags... but useful for testing
This commit is contained in:
niftynei
2020-12-09 18:10:17 -06:00
committed by Christian Decker
parent 205a7057c9
commit 327d9a3ff6
2 changed files with 25 additions and 5 deletions

View File

@@ -113,16 +113,16 @@ u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES);
#define OPT_LARGE_CHANNELS 18 #define OPT_LARGE_CHANNELS 18
#define OPT_ANCHOR_OUTPUTS 20 #define OPT_ANCHOR_OUTPUTS 20
/* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9:
* | 222/223 | `option_dual_fund` | ... IN9 ...
*/
#define OPT_DUAL_FUND 222
/* BOLT-9fc25cfd2895578c0b1ab701ebe6c1eb67a19623 #9: /* BOLT-9fc25cfd2895578c0b1ab701ebe6c1eb67a19623 #9:
* *
* | 102/103 | `option_onion_messages` |... INC+ ... * | 102/103 | `option_onion_messages` |... INC+ ...
*/ */
#if EXPERIMENTAL_FEATURES #if EXPERIMENTAL_FEATURES
#define OPT_ONION_MESSAGES 102 #define OPT_ONION_MESSAGES 102
/* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9:
* | 222/223 | `option_dual_fund` | ... IN9 ...
*/
#define OPT_DUAL_FUND 222
#endif #endif
#endif /* LIGHTNING_COMMON_FEATURES_H */ #endif /* LIGHTNING_COMMON_FEATURES_H */

View File

@@ -791,6 +791,14 @@ static char *opt_set_wumbo(struct lightningd *ld)
return NULL; return NULL;
} }
static char *opt_set_dual_fund(struct lightningd *ld)
{
feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL,
OPTIONAL_FEATURE(OPT_DUAL_FUND))));
return NULL;
}
static void register_opts(struct lightningd *ld) static void register_opts(struct lightningd *ld)
{ {
/* This happens before plugins started */ /* This happens before plugins started */
@@ -832,6 +840,13 @@ static void register_opts(struct lightningd *ld)
opt_set_wumbo, ld, opt_set_wumbo, ld,
"Allow channels larger than 0.16777215 BTC"); "Allow channels larger than 0.16777215 BTC");
opt_register_early_noarg("--experimental-dual-fund",
opt_set_dual_fund, ld,
"experimental: Advertise dual-funding"
" and allow peers to establish channels"
" via v2 channel open protocol");
opt_register_noarg("--help|-h", opt_lightningd_usage, ld, opt_register_noarg("--help|-h", opt_lightningd_usage, ld,
"Print this message."); "Print this message.");
opt_register_arg("--rgb", opt_set_rgb, NULL, ld, opt_register_arg("--rgb", opt_set_rgb, NULL, ld,
@@ -1242,6 +1257,11 @@ static void add_config(struct lightningd *ld,
feature_offered(ld->our_features feature_offered(ld->our_features
->bits[INIT_FEATURE], ->bits[INIT_FEATURE],
OPT_LARGE_CHANNELS)); OPT_LARGE_CHANNELS));
} else if (opt->cb == (void *)opt_set_dual_fund) {
json_add_bool(response, name0,
feature_offered(ld->our_features
->bits[INIT_FEATURE],
OPT_DUAL_FUND));
} else if (opt->cb == (void *)plugin_opt_flag_set) { } else if (opt->cb == (void *)plugin_opt_flag_set) {
/* Noop, they will get added below along with the /* Noop, they will get added below along with the
* OPT_HASARG options. */ * OPT_HASARG options. */