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

Function param_restrictions

plugins/commando.c:820–848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818}
819
820static struct command_result *param_restrictions(struct command *cmd,
821 const char *name,
822 const char *buffer,
823 const jsmntok_t *tok,
824 struct rune_restr ***restrs)
825{
826 if (json_tok_streq(buffer, tok, "readonly"))
827 *restrs = readonly_restrictions(cmd);
828 else if (tok->type == JSMN_ARRAY) {
829 size_t i;
830 const jsmntok_t *t;
831
832 *restrs = tal_arr(cmd, struct rune_restr *, tok->size);
833 json_for_each_arr(i, t, tok) {
834 (*restrs)[i] = rune_restr_from_json(*restrs, buffer, t);
835 if (!(*restrs)[i]) {
836 return command_fail_badparam(cmd, name, buffer, t,
837 "not a valid restriction (should be array)");
838 }
839 }
840 } else {
841 *restrs = tal_arr(cmd, struct rune_restr *, 1);
842 (*restrs)[0] = rune_restr_from_json(*restrs, buffer, tok);
843 if (!(*restrs)[0])
844 return command_fail_badparam(cmd, name, buffer, tok,
845 "not a valid restriction (should be array)");
846 }
847 return NULL;
848}
849
850static struct command_result *reply_with_rune(struct command *cmd,
851 const char *buf UNUSED,

Callers

nothing calls this directly

Calls 4

readonly_restrictionsFunction · 0.85
rune_restr_from_jsonFunction · 0.85
command_fail_badparamFunction · 0.85
json_tok_streqFunction · 0.50

Tested by

no test coverage detected