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

Function json_createrune

lightningd/runes.c:581–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579}
580
581static struct command_result *json_createrune(struct command *cmd,
582 const char *buffer,
583 const jsmntok_t *obj UNNEEDED,
584 const jsmntok_t *params)
585{
586 struct rune_and_string *ras;
587 struct rune_restr **restrs;
588
589 if (!param(cmd, buffer, params,
590 p_opt("rune", param_rune, &ras),
591 p_opt("restrictions", param_restrictions, &restrs),
592 NULL))
593 return command_param_failed();
594
595 if (ras != NULL ) {
596 for (size_t i = 0; i < tal_count(restrs); i++)
597 rune_add_restr(ras->rune, restrs[i]);
598 return reply_with_rune(cmd, NULL, NULL, ras->rune);
599 }
600
601 ras = tal(cmd, struct rune_and_string);
602 ras->rune = rune_derive_start(cmd, cmd->ld->runes->master,
603 tal_fmt(tmpctx, "%"PRIu64,
604 cmd->ld->runes->next_unique_id));
605 ras->runestr = rune_to_base64(tmpctx, ras->rune);
606
607 for (size_t i = 0; i < tal_count(restrs); i++)
608 rune_add_restr(ras->rune, restrs[i]);
609
610 /* Insert into DB*/
611 wallet_rune_insert(cmd->ld->wallet, ras->rune);
612 cmd->ld->runes->next_unique_id = cmd->ld->runes->next_unique_id + 1;
613 return reply_with_rune(cmd, NULL, NULL, ras->rune);
614}
615
616static const struct json_command creatrune_command = {
617 "createrune",

Callers

nothing calls this directly

Calls 7

rune_add_restrFunction · 0.85
reply_with_runeFunction · 0.85
rune_derive_startFunction · 0.85
rune_to_base64Function · 0.85
wallet_rune_insertFunction · 0.85
command_param_failedFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected