mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
dev-force-features: adds a second valid format for forcing features
The previous dev-force-features forced you to explicitly declare every desired feature bit in an array, for each set. Here, we allow you to also denote adding/subtracing a feature bit by just passing in the number of the bit to flip and the direction to turn it. e.g. 'dev-force-features': '+223' Will turn on opt_dual_fund/odd. 'dev-force-features': '-16' Will flag off opt_basic_mpp.
This commit is contained in:
parent
ddc9500a64
commit
21122af3a8
1 changed files with 23 additions and 2 deletions
|
@ -516,8 +516,29 @@ static char *opt_force_featureset(const char *optarg,
|
|||
struct lightningd *ld)
|
||||
{
|
||||
char **parts = tal_strsplit(tmpctx, optarg, "/", STR_EMPTY_OK);
|
||||
if (tal_count(parts) != NUM_FEATURE_PLACE)
|
||||
return "Expected 5 feature sets (init, globalinit, node_announce, channel, bolt11) separated by /";
|
||||
if (tal_count(parts) != NUM_FEATURE_PLACE) {
|
||||
if (!strstarts(optarg, "-") && !strstarts(optarg, "+"))
|
||||
return "Expected 5 feature sets (init, globalinit,"
|
||||
" node_announce, channel, bolt11) separated"
|
||||
" by / OR +/-<feature_num>";
|
||||
|
||||
char *endp;
|
||||
long int n = strtol(optarg + 1, &endp, 10);
|
||||
const struct feature_set *f;
|
||||
if (*endp || endp == optarg + 1)
|
||||
return "Invalid feature number";
|
||||
|
||||
f = feature_set_for_feature(NULL, n);
|
||||
if (strstarts(optarg, "-")
|
||||
&& !feature_set_sub(ld->our_features, take(f)))
|
||||
return "Feature unknown";
|
||||
|
||||
if (strstarts(optarg, "+")
|
||||
&& !feature_set_or(ld->our_features, take(f)))
|
||||
return "Feature already flagged-on";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
for (size_t i = 0; parts[i]; i++) {
|
||||
char **bits = tal_strsplit(tmpctx, parts[i], ",", STR_EMPTY_OK);
|
||||
tal_resize(&ld->our_features->bits[i], 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue