Skip to content

Commit

Permalink
runes: create and blacklist commands aliases
Browse files Browse the repository at this point in the history
- Added `invokerune` alias for `createrune`
- Added `destroyrune` alias for `blacklistrune`
  • Loading branch information
ShahanaFarooqui committed Jul 24, 2023
1 parent 5148fca commit 48e5f40
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
4 changes: 3 additions & 1 deletion doc/lightning-blacklistrune.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ DESCRIPTION

The **blacklistrune** RPC command allows you to effectively revoke the rune you have created (and any runes derived from that rune with additional restictions). Attempting to use these runes will be resulted in a `Blacklisted rune` error message.

Destroy a rune like in olden times with the **destroyrune** command.

All runes created by lightning have a unique sequential id within them and can be blacklisted in ranges for efficiency. The command always returns the blacklisted ranges on success. If no parameters are specified, no changes have been made. If start specified without end, that single rune is blacklisted. If end is also specified, every rune from start till end inclusive is blacklisted.

RETURN VALUE
Expand All @@ -32,7 +34,7 @@ Shahana Farooqui <<[email protected]>> is mainly responsible.
SEE ALSO
--------

lightning-commando-blacklist(7), lightning-listrunes(7)
lightning-commando-blacklist(7), lightning-showrunes(7)

RESOURCES
---------
Expand Down
3 changes: 3 additions & 0 deletions doc/lightning-createrune.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ you try, the rune will be rejected. There is no limit on how many
runes you can issue; the node simply decodes and checks them as they are
received.

Oh, I almost forgot. Runes can also be invoked like in ancient times with
the **invokerune** command. Feel the magical powers of a rune by invoking it.

If *rune* is supplied, the restrictions are simple appended to that
*rune* (it doesn't need to be a rune belonging to this node). If no
*rune* is supplied, a new one is constructed, with a new unique id.
Expand Down
28 changes: 22 additions & 6 deletions lightningd/runes.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static struct command_result *json_add_rune(struct lightningd *ld,
return NULL;
}

static struct command_result *json_listrunes(struct command *cmd,
static struct command_result *json_showrunes(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
const jsmntok_t *params)
Expand Down Expand Up @@ -339,13 +339,13 @@ static struct command_result *json_listrunes(struct command *cmd,
return command_success(cmd, response);
}

static const struct json_command listrunes_command = {
"listrunes",
static const struct json_command showrunes_command = {
"showrunes",
"utility",
json_listrunes,
"List a rune or list/decode an optional {rune}."
json_showrunes,
"Show the list of runes or decode an optional {rune}."
};
AUTODATA(json_command, &listrunes_command);
AUTODATA(json_command, &showrunes_command);

static struct rune_restr **readonly_restrictions(const tal_t *ctx)
{
Expand Down Expand Up @@ -535,6 +535,14 @@ static const struct json_command creatrune_command = {
};
AUTODATA(json_command, &creatrune_command);

static const struct json_command invokerune_command = {
"invokerune",
"utility",
json_createrune,
"Invoke or restrict an optional {rune} with optional {restrictions} and returns {rune}"
};
AUTODATA(json_command, &invokerune_command);

static void blacklist_merge(struct rune_blacklist *blacklist,
const struct rune_blacklist *entry)
{
Expand Down Expand Up @@ -636,6 +644,14 @@ static const struct json_command blacklistrune_command = {
};
AUTODATA(json_command, &blacklistrune_command);

static const struct json_command destroyrune_command = {
"destroyrune",
"utility",
json_blacklistrune,
"Destroy a rune or range of runes by taking an optional {start} and an optional {end} and returns {blacklist} array containing {start}, {end}"
};
AUTODATA(json_command, &destroyrune_command);

static const char *check_condition(const tal_t *ctx,
const struct rune *rune,
const struct rune_altern *alt,
Expand Down

0 comments on commit 48e5f40

Please sign in to comment.