![]() |
![]()
| ![]() |
![]()
NAMElightning-createrune -- Command to Create/Update Rune for Authorizing Remote Peer Access SYNOPSIScreaterune [rune] [restrictions] DESCRIPTIONCommand added in v23.08. The createrune RPC command creates a base64 string called a rune which can be used to access commands on this node. Each rune contains a unique id (a number starting at 0), and can have restrictions inside it. Nobody can remove restrictions from a rune: if 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.
RESTRICTION FORMATRestrictions are one or more alternatives. Each alternative is name operator value. The valid names are shown above. Note that if a value contains \, it must be preceeded by another \ to form valid JSON: * =: passes if equal ie. identical. e.g. method=withdraw * /: not equals, e.g. method/withdraw * ^: starts with, e.g. id^024b9a1fa8e006f1e3937f * $: ends with, e.g. id$381df1cc449605. * ~: contains, e.g. id~006f1e3937f65f66c40. * <: is a decimal integer, and is less than. e.g. time<1656759180 * >: is a decimal integer, and is greater than. e.g. time>1656759180 * {: preceeds in alphabetical order (or matches but is shorter), e.g. id{02ff. * }: follows in alphabetical order (or matches but is longer), e.g. id}02ff. * #: a comment, ignored, e.g. dumb example#. * !: only passes if the name does not exist. e.g. pnamedestination!. Every other operator except # fails if name does not exist! SHARING RUNESBecause anyone can add a restriction to a rune, you can always turn a normal rune into a read-only rune, or restrict access for 30 minutes from the time you give it to someone. Adding restrictions before sharing runes is best practice. If a rune has a ratelimit, any derived rune will have the same id, and thus will compete for that ratelimit. You might want to consider adding a tighter ratelimit to a rune before sharing it, so you will keep the remainder. For example, if your rune has a limit of 60 times per minute, adding a limit of 5 times per minute and handing that rune out means you can still use your original rune 55 times per minute. RETURN VALUEOn success, an object is returned, containing:
The following warnings may also be returned:
AUTHORRusty Russell <rusty@rustcorp.com.au> wrote the original Python commando.py plugin, the in-tree commando plugin, and this manual page. Shahana Farooqui <sfarooqui@blockstream.com> is mainly responsible for migrating commando-rune to createrune. SEE ALSOlightning-commando-rune(7), lightning-checkrune(7) RESOURCESMain web site: https://github.com/ElementsProject/lightning USAGE
$ lightning-cli decode tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y {
$ lightning-cli checkrune -k 'rune'=tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y 'method'='invoice' 'params'='{"amount_msat": 100000001, "label": "invoicelabel"', "description": "Checking rune validity"}' EXAMPLESExample 1: This creates a fresh rune which can do anything: Request: $ lightning-cli createrune { Response: { Example 2: We can add restrictions to that rune, like so: The readonly restriction is a short-cut for two restrictions: 1: ['method^list', 'method^get', 'method=summary']: You may call list, get or summary. 2: ['method/listdatastore']: But not listdatastore: that contains sensitive stuff! Request: $ lightning-cli createrune -k "rune"="zFMd1fjhrAYxUeFA54TjloZqOt8JrA_i_nYwIgXkag49MA==" "restrictions"="readonly" { Response: { Example 3: We can do the same manually (readonly), like so: Request: $ lightning-cli createrune -k "rune"="zFMd1fjhrAYxUeFA54TjloZqOt8JrA_i_nYwIgXkag49MA==" "restrictions"='[["method^list", "method^get", "method=summary"], ["method/listdatastore"]]' { Response: { Example 4: This will allow the rune to be used for id starting with 0266e4598d1d3c415f57, and for the method listpeers: Request: $ lightning-cli createrune -k "restrictions"='[["id^0266e4598d1d3c415f57"], ["method=listpeers"]]' { Response: { Example 5: This will allow the rune to be used for the method pay, and for the parameter amount_msat to be less than 10000: Request: $ lightning-cli createrune -k "restrictions"='[["method=pay"], ["pnameamountmsat<10000"]]' { Response: { Example 6: Let's create a rune which lets a specific peer run listpeers on themselves: Request: $ lightning-cli createrune -k "restrictions"='[["id=0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518"], ["method=listpeers"], ["pnum=1"], ["pnameid=0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518", "parr0=0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518"]]' { Response: { Example 7: This allows listpeers with 1 argument (pnum=1), which is either by name (pnameid), or position (parr0). We could shorten this in several ways: either allowing only positional or named parameters, or by testing the start of the parameters only. Here's an example which only checks the first 10 bytes of the listpeers parameter: Request: $ lightning-cli createrune -k "restrictions"='[["id=0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518"], ["method=listpeers"], ["pnum=1"], ["pnameid^0266e4598d1d3c415f57", "parr0^0266e4598d1d3c415f57"]]' { Response: { Example 8: Before we give this to our peer, let's add two more restrictions: that it only be usable for 24 hours from now (time<), and that it can only be used twice a minute (rate=2). date +%s can give us the current time in seconds: Request: $ lightning-cli createrune "8_CRIJ4arWAz72A4ILOZ46MESSJtQQQ9iQZjU28qulA9NCZpZD0wMjY2ZTQ1OThkMWQzYzQxNWY1NzJhODQ4ODgzMGI2MGY3ZTc0NGVkOTIzNWViMGIxYmE5MzI4M2IzMTVjMDM1MTgmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjY2ZTQ1OThkMWQzYzQxNWY1N3xwYXJyMF4wMjY2ZTQ1OThkMWQzYzQxNWY1Nw==" "[['time<"$(($(date +%s) + 24*60*60))"', 'rate=2']]" { Response: { Example 9: Now, let us create a rune with read-only restrictions, extended to only allow sending payments of less than 100,000 sats per day using either the pay or xpay method. Ideally, the condition would look something like: [["method^list or method^get or ((method=pay or method=xpay) and per=1day and pnameamount\_msat<100000001)"],["method/listdatastore"]]. However, since brackets and AND conditions within OR are currently not supported for rune creation, we can restructure the conditions as follows:
Request: $ lightning-cli createrune -k "restrictions"='[["method^list", "method^get", "method=summary", "method=pay", "method=xpay"], ["method/listdatastore"], ["method/pay", "per=1day"], ["method/pay", "pnameamount_msat<100000001"], ["method/xpay", "per=1day"], ["method/xpay", "pnameamount_msat<100000001"]]' { Response: {
|