From a649e8b51796edaf93effd964c2e28e8acd10d8a Mon Sep 17 00:00:00 2001 From: Shahana Farooqui Date: Tue, 25 Jul 2023 09:33:28 +0930 Subject: [PATCH] runes: create and blacklist commands aliases - Added `invokerune` alias for `createrune` - Added `destroyrune` alias for `blacklistrune` --- doc/lightning-blacklistrune.7.md | 2 ++ doc/lightning-createrune.7.md | 3 +++ lightningd/runes.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/doc/lightning-blacklistrune.7.md b/doc/lightning-blacklistrune.7.md index 081ed9015..64ba7c085 100644 --- a/doc/lightning-blacklistrune.7.md +++ b/doc/lightning-blacklistrune.7.md @@ -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 diff --git a/doc/lightning-createrune.7.md b/doc/lightning-createrune.7.md index e12fbe289..35d34176c 100644 --- a/doc/lightning-createrune.7.md +++ b/doc/lightning-createrune.7.md @@ -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. diff --git a/lightningd/runes.c b/lightningd/runes.c index dc40acf76..73fb67af1 100644 --- a/lightningd/runes.c +++ b/lightningd/runes.c @@ -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) { @@ -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,