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

Function json_createrune

lightningd/runes.c:571–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

569}
570
571static struct command_result *json_createrune(struct command *cmd,
572 const char *buffer,
573 const jsmntok_t *obj UNNEEDED,
574 const jsmntok_t *params)
575{
576 struct rune_and_string *ras;
577 struct rune_restr **restrs;
578
579 if (!param(cmd, buffer, params,
580 p_opt("rune", param_rune, &ras),
581 p_opt("restrictions", param_restrictions, &restrs),
582 NULL))
583 return command_param_failed();
584
585 if (ras != NULL ) {
586 for (size_t i = 0; i < tal_count(restrs); i++)
587 rune_add_restr(ras->rune, restrs[i]);
588 return reply_with_rune(cmd, NULL, NULL, ras->rune);
589 }
590
591 ras = tal(cmd, struct rune_and_string);
592 ras->rune = rune_derive_start(cmd, cmd->ld->runes->master,
593 tal_fmt(tmpctx, "%"PRIu64,
594 cmd->ld->runes->next_unique_id));
595 ras->runestr = rune_to_base64(tmpctx, ras->rune);
596
597 for (size_t i = 0; i < tal_count(restrs); i++)
598 rune_add_restr(ras->rune, restrs[i]);
599
600 /* Insert into DB*/
601 wallet_rune_insert(cmd->ld->wallet, ras->rune);
602 cmd->ld->runes->next_unique_id = cmd->ld->runes->next_unique_id + 1;
603 return reply_with_rune(cmd, NULL, NULL, ras->rune);
604}
605
606static const struct json_command creatrune_command = {
607 "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