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

Function json_blacklistrune

lightningd/runes.c:634–681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634static struct command_result *json_blacklistrune(struct command *cmd,
635 const char *buffer,
636 const jsmntok_t *obj UNNEEDED,
637 const jsmntok_t *params)
638{
639 u64 *start, *end;
640 struct rune_blacklist *blist;
641 bool *relist;
642
643 if (!param_check(cmd, buffer, params,
644 p_opt("start", param_u64, &start),
645 p_opt("end", param_u64, &end),
646 p_opt_def("relist", param_bool, &relist, false),
647 NULL))
648 return command_param_failed();
649
650 if (end && !start) {
651 return command_fail(cmd, JSONRPC2_INVALID_PARAMS, "Can not specify end without start");
652 }
653
654 if (!end) {
655 end = start;
656 }
657
658 if (end && *end >= MAX_BLACKLIST_NUM) {
659 return command_fail(cmd, JSONRPC2_INVALID_PARAMS, "Cannot blacklist beyond %u", MAX_BLACKLIST_NUM);
660 }
661
662 if (command_check_only(cmd))
663 return command_check_done(cmd);
664
665 if (!start) {
666 blist = bitmap_to_blacklist(cmd, cmd->ld->runes->blist_bitmap, MAX_BLACKLIST_NUM);
667 return list_blacklist(cmd, blist);
668 }
669
670 /* Include end */
671 if (*relist)
672 bitmap_zero_range(cmd->ld->runes->blist_bitmap, *start, (*end)+1);
673 else
674 bitmap_fill_range(cmd->ld->runes->blist_bitmap, *start, (*end)+1);
675
676 /* Convert to list once, use for db and for list_blacklist */
677 blist = bitmap_to_blacklist(cmd, cmd->ld->runes->blist_bitmap, MAX_BLACKLIST_NUM);
678 wallet_set_blacklist(cmd->ld->wallet, blist);
679
680 return list_blacklist(cmd, blist);
681}
682
683static const struct json_command blacklistrune_command = {
684 "blacklistrune",

Callers

nothing calls this directly

Calls 10

param_checkFunction · 0.85
bitmap_to_blacklistFunction · 0.85
list_blacklistFunction · 0.85
bitmap_zero_rangeFunction · 0.85
bitmap_fill_rangeFunction · 0.85
wallet_set_blacklistFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70

Tested by

no test coverage detected