MCPcopy Create free account
hub / github.com/ElementsProject/lightning / opt_force_featureset

Function opt_force_featureset

lightningd/options.c:632–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632static char *opt_force_featureset(const char *optarg,
633 struct lightningd *ld)
634{
635 char **parts = tal_strsplit(tmpctx, optarg, "/", STR_EMPTY_OK);
636 if (tal_count(parts) != NUM_FEATURE_PLACE + 1) {
637 if (!strstarts(optarg, "-") && !strstarts(optarg, "+"))
638 return "Expected 5 feature sets (init/globalinit/"
639 " node_announce/channel/bolt11) each terminated by /"
640 " OR +/-<single_bit_num>";
641
642 char *endp;
643 long int n = strtol(optarg + 1, &endp, 10);
644 const struct feature_set *f;
645 if (*endp || endp == optarg + 1)
646 return "Invalid feature number";
647
648 f = feature_set_for_feature(NULL, n);
649 if (strstarts(optarg, "-")
650 && !feature_set_sub(ld->our_features, take(f)))
651 return "Feature unknown";
652
653 if (strstarts(optarg, "+")
654 && !feature_set_or(ld->our_features, take(f)))
655 return "Feature already flagged-on";
656
657 return NULL;
658 }
659 for (size_t i = 0; parts[i]; i++) {
660 char **bits = tal_strsplit(tmpctx, parts[i], ",", STR_EMPTY_OK);
661 tal_resize(&ld->our_features->bits[i], 0);
662
663 for (size_t j = 0; bits[j]; j++) {
664 char *endp;
665 long int n = strtol(bits[j], &endp, 10);
666 if (*endp || endp == bits[j])
667 return "Invalid bitnumber";
668 set_feature_bit(&ld->our_features->bits[i], n);
669 }
670 }
671 return NULL;
672}
673
674static void dev_register_opts(struct lightningd *ld)
675{

Callers

nothing calls this directly

Calls 4

feature_set_subFunction · 0.85
set_feature_bitFunction · 0.85
feature_set_for_featureFunction · 0.50
feature_set_orFunction · 0.50

Tested by

no test coverage detected