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

Function opt_force_featureset

lightningd/options.c:704–744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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