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

Function opt_force_featureset

lightningd/options.c:706–746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

704}
705
706static char *opt_force_featureset(const char *optarg,
707 struct lightningd *ld)
708{
709 char **parts = tal_strsplit(tmpctx, optarg, "/", STR_EMPTY_OK);
710 if (tal_count(parts) != NUM_FEATURE_PLACE + 1) {
711 if (!strstarts(optarg, "-") && !strstarts(optarg, "+"))
712 return "Expected 8 feature sets (init/globalinit/"
713 " node_announce/channel/bolt11/b12offer/b12invreq/b12inv) each terminated by /"
714 " OR +/-<single_bit_num>";
715
716 char *endp;
717 long int n = strtol(optarg + 1, &endp, 10);
718 const struct feature_set *f;
719 if (*endp || endp == optarg + 1)
720 return "Invalid feature number";
721
722 f = feature_set_for_feature(NULL, n);
723 if (strstarts(optarg, "-")) {
724 feature_set_sub(ld->our_features, take(f));
725 }
726
727 if (strstarts(optarg, "+")
728 && !feature_set_or(ld->our_features, take(f)))
729 return "Feature already flagged-on";
730
731 return NULL;
732 }
733 for (size_t i = 0; parts[i]; i++) {
734 char **bits = tal_strsplit(tmpctx, parts[i], ",", STR_EMPTY_OK);
735 tal_resize(&ld->our_features->bits[i], 0);
736
737 for (size_t j = 0; bits[j]; j++) {
738 char *endp;
739 long int n = strtol(bits[j], &endp, 10);
740 if (*endp || endp == bits[j])
741 return "Invalid bitnumber";
742 set_feature_bit(&ld->our_features->bits[i], n);
743 }
744 }
745 return NULL;
746}
747
748static char *opt_ignore(void *unused)
749{

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected