| 630 | } |
| 631 | |
| 632 | static 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 | |
| 674 | static void dev_register_opts(struct lightningd *ld) |
| 675 | { |
nothing calls this directly
no test coverage detected