mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 22:31:48 +01:00
doc: Add new createrune example
- Moved the `Usage` section further down in `createrune` and `commando-rune` for improved UX. - Added a new example for creating a rune with `read-only` restrictions, extending it to allow only payments of `less than 100,000 sats per day` using the `pay` or `xpay` methods. - Adjusted formatting by appending an extra space after the `dependentUpon` condition, fixing `[*start* [*end*]][*relist*]` to `[*start* [*end*]] [*relist*]`. - Relocated `Examples` from the expandable section to a standard heading, as examples are now already placed at the end of the page. Changelog-None.
This commit is contained in:
parent
0db282a069
commit
54555ce5e7
8 changed files with 839 additions and 98 deletions
|
@ -5873,6 +5873,127 @@
|
|||
}
|
||||
],
|
||||
"restrictions_as_english": "id equal to 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518 AND method equal to listpeers AND pnum equal to 1 AND pnameid starts with 0266e4598d1d3c415f57 OR parr0 starts with 0266e4598d1d3c415f57"
|
||||
},
|
||||
{
|
||||
"rune": "iP1FQEsFmPsu-XW7w8uXIJaJb7jU9PqOfkmXlOyWMuA9NSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5fG1ldGhvZD1wYXl8bWV0aG9kPXhwYXkmbWV0aG9kL2xpc3RkYXRhc3RvcmUmbWV0aG9kL3BheXxwZXI9MWRheSZtZXRob2QvcGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAxJm1ldGhvZC94cGF5fHBlcj0xZGF5Jm1ldGhvZC94cGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAx",
|
||||
"unique_id": "5",
|
||||
"restrictions": [
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "list",
|
||||
"condition": "^",
|
||||
"english": "method starts with list"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "get",
|
||||
"condition": "^",
|
||||
"english": "method starts with get"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "summary",
|
||||
"condition": "=",
|
||||
"english": "method equal to summary"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "=",
|
||||
"english": "method equal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "=",
|
||||
"english": "method equal to xpay"
|
||||
}
|
||||
],
|
||||
"english": "method starts with list OR method starts with get OR method equal to summary OR method equal to pay OR method equal to xpay"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "listdatastore",
|
||||
"condition": "/",
|
||||
"english": "method unequal to listdatastore"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to listdatastore"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "per",
|
||||
"value": "1day",
|
||||
"condition": "=",
|
||||
"english": "per equal to 1day"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to pay OR per equal to 1day"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "pnameamount_msat",
|
||||
"value": "100000001",
|
||||
"condition": "<",
|
||||
"english": "pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to pay OR pnameamount_msat < 100000001"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to xpay"
|
||||
},
|
||||
{
|
||||
"fieldname": "per",
|
||||
"value": "1day",
|
||||
"condition": "=",
|
||||
"english": "per equal to 1day"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to xpay OR per equal to 1day"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to xpay"
|
||||
},
|
||||
{
|
||||
"fieldname": "pnameamount_msat",
|
||||
"value": "100000001",
|
||||
"condition": "<",
|
||||
"english": "pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to xpay OR pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"restrictions_as_english": "method starts with list OR method starts with get OR method equal to summary OR method equal to pay OR method equal to xpay AND method unequal to listdatastore AND method unequal to pay OR per equal to 1day AND method unequal to pay OR pnameamount_msat < 100000001 AND method unequal to xpay OR per equal to 1day AND method unequal to xpay OR pnameamount_msat < 100000001"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -5986,8 +6107,25 @@
|
|||
"* `!`: only passes if the *name* does *not* exist. e.g. `pnamedestination!`.",
|
||||
"Every other operator except `#` fails if *name* does not exist!"
|
||||
],
|
||||
"sharing_runes": [
|
||||
"Because 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 you 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."
|
||||
],
|
||||
"author": [
|
||||
"Rusty Russell <<rusty@rustcorp.com.au>> wrote the original Python commando.py plugin, the in-tree commando plugin, and this manual page.",
|
||||
"",
|
||||
"Christian Decker came up with the name \"commando\", which almost excuses his previous adoption of the name \"Eltoo\"."
|
||||
],
|
||||
"see_also": [
|
||||
"lightning-commando(7)",
|
||||
"lightning-decode(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
],
|
||||
"usage": [
|
||||
"You can use lightning-decode(7) to examine runes you have been given:",
|
||||
"- You can use lightning-decode(7) to examine runes you have been given:",
|
||||
"",
|
||||
"```shell",
|
||||
"lightning-cli decode tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y",
|
||||
|
@ -6036,25 +6174,14 @@
|
|||
" ],",
|
||||
" \"valid\": true",
|
||||
"}",
|
||||
"```",
|
||||
"",
|
||||
"- You can use lightning-checkrune(7) to verify whether a rune is valid for a specific method and its parameters:",
|
||||
"",
|
||||
"```shell",
|
||||
"lightning-cli checkrune -k 'rune'=tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y 'method'='invoice' 'params'='{\"amount_msat\": 100000001, \"label\": \"invoicelabel\"', \"description\": \"Checking rune validity\"}'",
|
||||
"```"
|
||||
],
|
||||
"sharing_runes": [
|
||||
"Because 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 you 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."
|
||||
],
|
||||
"author": [
|
||||
"Rusty Russell <<rusty@rustcorp.com.au>> wrote the original Python commando.py plugin, the in-tree commando plugin, and this manual page.",
|
||||
"",
|
||||
"Christian Decker came up with the name \"commando\", which almost excuses his previous adoption of the name \"Eltoo\"."
|
||||
],
|
||||
"see_also": [
|
||||
"lightning-commando(7)",
|
||||
"lightning-decode(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
],
|
||||
"examples": [
|
||||
{
|
||||
"description": [
|
||||
|
@ -6247,6 +6374,60 @@
|
|||
"rune": "7nvN7uG2CyTOXe3dYQL38YVdGsnD6d5VNNyeHVl6inc9NCZpZD0wMjY2ZTQ1OThkMWQzYzQxNWY1NzJhODQ4ODgzMGI2MGY3ZTc0NGVkOTIzNWViMGIxYmE5MzI4M2IzMTVjMDM1MTgmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjY2ZTQ1OThkMWQzYzQxNWY1N3xwYXJyMF4wMjY2ZTQ1OThkMWQzYzQxNWY1NyZ0aW1lPCIkKCgkKGRhdGUgKyVzKSArIDI0KjYwKjYwKSkifHJhdGU9Mg==",
|
||||
"unique_id": "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": [
|
||||
"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:",
|
||||
"",
|
||||
"- 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"
|
||||
],
|
||||
"request": {
|
||||
"id": "example:commando-rune#9",
|
||||
"method": "commando-rune",
|
||||
"params": {
|
||||
"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": {
|
||||
"rune": "QqgK4ZNJOwMjhUAQhHcnkTBXRoLghhPcJVR_Zew97ug9NSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5fG1ldGhvZD1wYXl8bWV0aG9kPXhwYXkmbWV0aG9kL2xpc3RkYXRhc3RvcmUmbWV0aG9kL3BheXxwZXI9MWRheSZtZXRob2QvcGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAxJm1ldGhvZC94cGF5fHBlcj0xZGF5Jm1ldGhvZC94cGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAx",
|
||||
"unique_id": "5"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -7150,8 +7331,25 @@
|
|||
"* `!`: only passes if the *name* does *not* exist. e.g. `pnamedestination!`.",
|
||||
"Every other operator except `#` fails if *name* does not exist!"
|
||||
],
|
||||
"sharing_runes": [
|
||||
"Because 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."
|
||||
],
|
||||
"author": [
|
||||
"Rusty 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_also": [
|
||||
"lightning-commando-rune(7)",
|
||||
"lightning-checkrune(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
],
|
||||
"usage": [
|
||||
"You can use lightning-decode(7) to examine runes you have been given:",
|
||||
"- You can use lightning-decode(7) to examine runes you have been given:",
|
||||
"",
|
||||
"```shell",
|
||||
"lightning-cli decode tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y",
|
||||
|
@ -7200,25 +7398,14 @@
|
|||
" ],",
|
||||
" \"valid\": true",
|
||||
"}",
|
||||
"```",
|
||||
"",
|
||||
"- You can use lightning-checkrune(7) to verify whether a rune is valid for a specific method and its parameters:",
|
||||
"",
|
||||
"```shell",
|
||||
"lightning-cli checkrune -k 'rune'=tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y 'method'='invoice' 'params'='{\"amount_msat\": 100000001, \"label\": \"invoicelabel\"', \"description\": \"Checking rune validity\"}'",
|
||||
"```"
|
||||
],
|
||||
"sharing_runes": [
|
||||
"Because 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 you 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."
|
||||
],
|
||||
"author": [
|
||||
"Rusty 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_also": [
|
||||
"lightning-commando-rune(7)",
|
||||
"lightning-checkrune(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
],
|
||||
"examples": [
|
||||
{
|
||||
"description": [
|
||||
|
@ -7411,6 +7598,60 @@
|
|||
"rune": "GJb2PC-4jYslzIVz6-425bOtpkz_A_zaEhekPlrXdj09NCZpZD0wMjY2ZTQ1OThkMWQzYzQxNWY1NzJhODQ4ODgzMGI2MGY3ZTc0NGVkOTIzNWViMGIxYmE5MzI4M2IzMTVjMDM1MTgmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjY2ZTQ1OThkMWQzYzQxNWY1N3xwYXJyMF4wMjY2ZTQ1OThkMWQzYzQxNWY1NyZ0aW1lPCIkKCgkKGRhdGUgKyVzKSArIDI0KjYwKjYwKSkifHJhdGU9Mg==",
|
||||
"unique_id": "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": [
|
||||
"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:",
|
||||
"",
|
||||
"- 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"
|
||||
],
|
||||
"request": {
|
||||
"id": "example:createrune#9",
|
||||
"method": "createrune",
|
||||
"params": {
|
||||
"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": {
|
||||
"rune": "iP1FQEsFmPsu-XW7w8uXIJaJb7jU9PqOfkmXlOyWMuA9NSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5fG1ldGhvZD1wYXl8bWV0aG9kPXhwYXkmbWV0aG9kL2xpc3RkYXRhc3RvcmUmbWV0aG9kL3BheXxwZXI9MWRheSZtZXRob2QvcGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAxJm1ldGhvZC94cGF5fHBlcj0xZGF5Jm1ldGhvZC94cGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAx",
|
||||
"unique_id": "5"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -32878,6 +33119,127 @@
|
|||
}
|
||||
],
|
||||
"restrictions_as_english": "id equal to 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518 AND method equal to listpeers AND pnum equal to 1 AND pnameid starts with 0266e4598d1d3c415f57 OR parr0 starts with 0266e4598d1d3c415f57"
|
||||
},
|
||||
{
|
||||
"rune": "iP1FQEsFmPsu-XW7w8uXIJaJb7jU9PqOfkmXlOyWMuA9NSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5fG1ldGhvZD1wYXl8bWV0aG9kPXhwYXkmbWV0aG9kL2xpc3RkYXRhc3RvcmUmbWV0aG9kL3BheXxwZXI9MWRheSZtZXRob2QvcGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAxJm1ldGhvZC94cGF5fHBlcj0xZGF5Jm1ldGhvZC94cGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAx",
|
||||
"unique_id": "5",
|
||||
"restrictions": [
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "list",
|
||||
"condition": "^",
|
||||
"english": "method starts with list"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "get",
|
||||
"condition": "^",
|
||||
"english": "method starts with get"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "summary",
|
||||
"condition": "=",
|
||||
"english": "method equal to summary"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "=",
|
||||
"english": "method equal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "=",
|
||||
"english": "method equal to xpay"
|
||||
}
|
||||
],
|
||||
"english": "method starts with list OR method starts with get OR method equal to summary OR method equal to pay OR method equal to xpay"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "listdatastore",
|
||||
"condition": "/",
|
||||
"english": "method unequal to listdatastore"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to listdatastore"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "per",
|
||||
"value": "1day",
|
||||
"condition": "=",
|
||||
"english": "per equal to 1day"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to pay OR per equal to 1day"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "pnameamount_msat",
|
||||
"value": "100000001",
|
||||
"condition": "<",
|
||||
"english": "pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to pay OR pnameamount_msat < 100000001"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to xpay"
|
||||
},
|
||||
{
|
||||
"fieldname": "per",
|
||||
"value": "1day",
|
||||
"condition": "=",
|
||||
"english": "per equal to 1day"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to xpay OR per equal to 1day"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to xpay"
|
||||
},
|
||||
{
|
||||
"fieldname": "pnameamount_msat",
|
||||
"value": "100000001",
|
||||
"condition": "<",
|
||||
"english": "pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to xpay OR pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"restrictions_as_english": "method starts with list OR method starts with get OR method equal to summary OR method equal to pay OR method equal to xpay AND method unequal to listdatastore AND method unequal to pay OR per equal to 1day AND method unequal to pay OR pnameamount_msat < 100000001 AND method unequal to xpay OR per equal to 1day AND method unequal to xpay OR pnameamount_msat < 100000001"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -399,6 +399,127 @@
|
|||
}
|
||||
],
|
||||
"restrictions_as_english": "id equal to 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518 AND method equal to listpeers AND pnum equal to 1 AND pnameid starts with 0266e4598d1d3c415f57 OR parr0 starts with 0266e4598d1d3c415f57"
|
||||
},
|
||||
{
|
||||
"rune": "iP1FQEsFmPsu-XW7w8uXIJaJb7jU9PqOfkmXlOyWMuA9NSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5fG1ldGhvZD1wYXl8bWV0aG9kPXhwYXkmbWV0aG9kL2xpc3RkYXRhc3RvcmUmbWV0aG9kL3BheXxwZXI9MWRheSZtZXRob2QvcGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAxJm1ldGhvZC94cGF5fHBlcj0xZGF5Jm1ldGhvZC94cGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAx",
|
||||
"unique_id": "5",
|
||||
"restrictions": [
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "list",
|
||||
"condition": "^",
|
||||
"english": "method starts with list"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "get",
|
||||
"condition": "^",
|
||||
"english": "method starts with get"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "summary",
|
||||
"condition": "=",
|
||||
"english": "method equal to summary"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "=",
|
||||
"english": "method equal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "=",
|
||||
"english": "method equal to xpay"
|
||||
}
|
||||
],
|
||||
"english": "method starts with list OR method starts with get OR method equal to summary OR method equal to pay OR method equal to xpay"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "listdatastore",
|
||||
"condition": "/",
|
||||
"english": "method unequal to listdatastore"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to listdatastore"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "per",
|
||||
"value": "1day",
|
||||
"condition": "=",
|
||||
"english": "per equal to 1day"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to pay OR per equal to 1day"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "pnameamount_msat",
|
||||
"value": "100000001",
|
||||
"condition": "<",
|
||||
"english": "pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to pay OR pnameamount_msat < 100000001"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to xpay"
|
||||
},
|
||||
{
|
||||
"fieldname": "per",
|
||||
"value": "1day",
|
||||
"condition": "=",
|
||||
"english": "per equal to 1day"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to xpay OR per equal to 1day"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to xpay"
|
||||
},
|
||||
{
|
||||
"fieldname": "pnameamount_msat",
|
||||
"value": "100000001",
|
||||
"condition": "<",
|
||||
"english": "pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to xpay OR pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"restrictions_as_english": "method starts with list OR method starts with get OR method equal to summary OR method equal to pay OR method equal to xpay AND method unequal to listdatastore AND method unequal to pay OR per equal to 1day AND method unequal to pay OR pnameamount_msat < 100000001 AND method unequal to xpay OR per equal to 1day AND method unequal to xpay OR pnameamount_msat < 100000001"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -105,8 +105,25 @@
|
|||
"* `!`: only passes if the *name* does *not* exist. e.g. `pnamedestination!`.",
|
||||
"Every other operator except `#` fails if *name* does not exist!"
|
||||
],
|
||||
"sharing_runes": [
|
||||
"Because 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 you 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."
|
||||
],
|
||||
"author": [
|
||||
"Rusty Russell <<rusty@rustcorp.com.au>> wrote the original Python commando.py plugin, the in-tree commando plugin, and this manual page.",
|
||||
"",
|
||||
"Christian Decker came up with the name \"commando\", which almost excuses his previous adoption of the name \"Eltoo\"."
|
||||
],
|
||||
"see_also": [
|
||||
"lightning-commando(7)",
|
||||
"lightning-decode(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
],
|
||||
"usage": [
|
||||
"You can use lightning-decode(7) to examine runes you have been given:",
|
||||
"- You can use lightning-decode(7) to examine runes you have been given:",
|
||||
"",
|
||||
"```shell",
|
||||
"lightning-cli decode tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y",
|
||||
|
@ -155,25 +172,14 @@
|
|||
" ],",
|
||||
" \"valid\": true",
|
||||
"}",
|
||||
"```",
|
||||
"",
|
||||
"- You can use lightning-checkrune(7) to verify whether a rune is valid for a specific method and its parameters:",
|
||||
"",
|
||||
"```shell",
|
||||
"lightning-cli checkrune -k 'rune'=tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y 'method'='invoice' 'params'='{\"amount_msat\": 100000001, \"label\": \"invoicelabel\"', \"description\": \"Checking rune validity\"}'",
|
||||
"```"
|
||||
],
|
||||
"sharing_runes": [
|
||||
"Because 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 you 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."
|
||||
],
|
||||
"author": [
|
||||
"Rusty Russell <<rusty@rustcorp.com.au>> wrote the original Python commando.py plugin, the in-tree commando plugin, and this manual page.",
|
||||
"",
|
||||
"Christian Decker came up with the name \"commando\", which almost excuses his previous adoption of the name \"Eltoo\"."
|
||||
],
|
||||
"see_also": [
|
||||
"lightning-commando(7)",
|
||||
"lightning-decode(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
],
|
||||
"examples": [
|
||||
{
|
||||
"description": [
|
||||
|
@ -366,6 +372,60 @@
|
|||
"rune": "7nvN7uG2CyTOXe3dYQL38YVdGsnD6d5VNNyeHVl6inc9NCZpZD0wMjY2ZTQ1OThkMWQzYzQxNWY1NzJhODQ4ODgzMGI2MGY3ZTc0NGVkOTIzNWViMGIxYmE5MzI4M2IzMTVjMDM1MTgmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjY2ZTQ1OThkMWQzYzQxNWY1N3xwYXJyMF4wMjY2ZTQ1OThkMWQzYzQxNWY1NyZ0aW1lPCIkKCgkKGRhdGUgKyVzKSArIDI0KjYwKjYwKSkifHJhdGU9Mg==",
|
||||
"unique_id": "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": [
|
||||
"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:",
|
||||
"",
|
||||
"- 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"
|
||||
],
|
||||
"request": {
|
||||
"id": "example:commando-rune#9",
|
||||
"method": "commando-rune",
|
||||
"params": {
|
||||
"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": {
|
||||
"rune": "QqgK4ZNJOwMjhUAQhHcnkTBXRoLghhPcJVR_Zew97ug9NSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5fG1ldGhvZD1wYXl8bWV0aG9kPXhwYXkmbWV0aG9kL2xpc3RkYXRhc3RvcmUmbWV0aG9kL3BheXxwZXI9MWRheSZtZXRob2QvcGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAxJm1ldGhvZC94cGF5fHBlcj0xZGF5Jm1ldGhvZC94cGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAx",
|
||||
"unique_id": "5"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -108,8 +108,25 @@
|
|||
"* `!`: only passes if the *name* does *not* exist. e.g. `pnamedestination!`.",
|
||||
"Every other operator except `#` fails if *name* does not exist!"
|
||||
],
|
||||
"sharing_runes": [
|
||||
"Because 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."
|
||||
],
|
||||
"author": [
|
||||
"Rusty 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_also": [
|
||||
"lightning-commando-rune(7)",
|
||||
"lightning-checkrune(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
],
|
||||
"usage": [
|
||||
"You can use lightning-decode(7) to examine runes you have been given:",
|
||||
"- You can use lightning-decode(7) to examine runes you have been given:",
|
||||
"",
|
||||
"```shell",
|
||||
"lightning-cli decode tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y",
|
||||
|
@ -158,25 +175,14 @@
|
|||
" ],",
|
||||
" \"valid\": true",
|
||||
"}",
|
||||
"```",
|
||||
"",
|
||||
"- You can use lightning-checkrune(7) to verify whether a rune is valid for a specific method and its parameters:",
|
||||
"",
|
||||
"```shell",
|
||||
"lightning-cli checkrune -k 'rune'=tU-RLjMiDpY2U0o3W1oFowar36RFGpWloPbW9-RuZdo9MyZpZD0wMjRiOWExZmE4ZTAwNmYxZTM5MzdmNjVmNjZjNDA4ZTZkYThlMWNhNzI4ZWE0MzIyMmE3MzgxZGYxY2M0NDk2MDUmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjRiOWExZmE4ZTAwNmYxZTM5M3xwYXJyMF4wMjRiOWExZmE4ZTAwNmYxZTM5MyZ0aW1lPDE2NTY5MjA1MzgmcmF0ZT0y 'method'='invoice' 'params'='{\"amount_msat\": 100000001, \"label\": \"invoicelabel\"', \"description\": \"Checking rune validity\"}'",
|
||||
"```"
|
||||
],
|
||||
"sharing_runes": [
|
||||
"Because 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 you 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."
|
||||
],
|
||||
"author": [
|
||||
"Rusty 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_also": [
|
||||
"lightning-commando-rune(7)",
|
||||
"lightning-checkrune(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
],
|
||||
"examples": [
|
||||
{
|
||||
"description": [
|
||||
|
@ -369,6 +375,60 @@
|
|||
"rune": "GJb2PC-4jYslzIVz6-425bOtpkz_A_zaEhekPlrXdj09NCZpZD0wMjY2ZTQ1OThkMWQzYzQxNWY1NzJhODQ4ODgzMGI2MGY3ZTc0NGVkOTIzNWViMGIxYmE5MzI4M2IzMTVjMDM1MTgmbWV0aG9kPWxpc3RwZWVycyZwbnVtPTEmcG5hbWVpZF4wMjY2ZTQ1OThkMWQzYzQxNWY1N3xwYXJyMF4wMjY2ZTQ1OThkMWQzYzQxNWY1NyZ0aW1lPCIkKCgkKGRhdGUgKyVzKSArIDI0KjYwKjYwKSkifHJhdGU9Mg==",
|
||||
"unique_id": "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": [
|
||||
"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:",
|
||||
"",
|
||||
"- 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"
|
||||
],
|
||||
"request": {
|
||||
"id": "example:createrune#9",
|
||||
"method": "createrune",
|
||||
"params": {
|
||||
"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": {
|
||||
"rune": "iP1FQEsFmPsu-XW7w8uXIJaJb7jU9PqOfkmXlOyWMuA9NSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5fG1ldGhvZD1wYXl8bWV0aG9kPXhwYXkmbWV0aG9kL2xpc3RkYXRhc3RvcmUmbWV0aG9kL3BheXxwZXI9MWRheSZtZXRob2QvcGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAxJm1ldGhvZC94cGF5fHBlcj0xZGF5Jm1ldGhvZC94cGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAx",
|
||||
"unique_id": "5"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -374,6 +374,127 @@
|
|||
}
|
||||
],
|
||||
"restrictions_as_english": "id equal to 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518 AND method equal to listpeers AND pnum equal to 1 AND pnameid starts with 0266e4598d1d3c415f57 OR parr0 starts with 0266e4598d1d3c415f57"
|
||||
},
|
||||
{
|
||||
"rune": "iP1FQEsFmPsu-XW7w8uXIJaJb7jU9PqOfkmXlOyWMuA9NSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5fG1ldGhvZD1wYXl8bWV0aG9kPXhwYXkmbWV0aG9kL2xpc3RkYXRhc3RvcmUmbWV0aG9kL3BheXxwZXI9MWRheSZtZXRob2QvcGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAxJm1ldGhvZC94cGF5fHBlcj0xZGF5Jm1ldGhvZC94cGF5fHBuYW1lYW1vdW50X21zYXQ8MTAwMDAwMDAx",
|
||||
"unique_id": "5",
|
||||
"restrictions": [
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "list",
|
||||
"condition": "^",
|
||||
"english": "method starts with list"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "get",
|
||||
"condition": "^",
|
||||
"english": "method starts with get"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "summary",
|
||||
"condition": "=",
|
||||
"english": "method equal to summary"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "=",
|
||||
"english": "method equal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "=",
|
||||
"english": "method equal to xpay"
|
||||
}
|
||||
],
|
||||
"english": "method starts with list OR method starts with get OR method equal to summary OR method equal to pay OR method equal to xpay"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "listdatastore",
|
||||
"condition": "/",
|
||||
"english": "method unequal to listdatastore"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to listdatastore"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "per",
|
||||
"value": "1day",
|
||||
"condition": "=",
|
||||
"english": "per equal to 1day"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to pay OR per equal to 1day"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "pay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to pay"
|
||||
},
|
||||
{
|
||||
"fieldname": "pnameamount_msat",
|
||||
"value": "100000001",
|
||||
"condition": "<",
|
||||
"english": "pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to pay OR pnameamount_msat < 100000001"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to xpay"
|
||||
},
|
||||
{
|
||||
"fieldname": "per",
|
||||
"value": "1day",
|
||||
"condition": "=",
|
||||
"english": "per equal to 1day"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to xpay OR per equal to 1day"
|
||||
},
|
||||
{
|
||||
"alternatives": [
|
||||
{
|
||||
"fieldname": "method",
|
||||
"value": "xpay",
|
||||
"condition": "/",
|
||||
"english": "method unequal to xpay"
|
||||
},
|
||||
{
|
||||
"fieldname": "pnameamount_msat",
|
||||
"value": "100000001",
|
||||
"condition": "<",
|
||||
"english": "pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"english": "method unequal to xpay OR pnameamount_msat < 100000001"
|
||||
}
|
||||
],
|
||||
"restrictions_as_english": "method starts with list OR method starts with get OR method equal to summary OR method equal to pay OR method equal to xpay AND method unequal to listdatastore AND method unequal to pay OR per equal to 1day AND method unequal to pay OR pnameamount_msat < 100000001 AND method unequal to xpay OR per equal to 1day AND method unequal to xpay OR pnameamount_msat < 100000001"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -767,6 +767,19 @@ def generate_runes_examples(l1, l2, l3):
|
|||
update_example(node=l2, method='createrune', params={'restrictions': [[f'id={l1.info["id"]}'], ['method=listpeers'], ['pnum=1'], [f'pnameid={l1.info["id"]}', f'parr0={l1.info["id"]}']]}, description=["Let's create a rune which lets a specific peer run listpeers on themselves:"])
|
||||
rune_l25 = update_example(node=l2, method='createrune', params={'restrictions': [[f'id={l1.info["id"]}'], ['method=listpeers'], ['pnum=1'], [f'pnameid^{trimmed_id}', f'parr0^{trimmed_id}']]}, description=["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:"])
|
||||
update_example(node=l2, method='createrune', params=[rune_l25['rune'], [['time<"$(($(date +%s) + 24*60*60))"', 'rate=2']]], description=["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:"])
|
||||
update_example(node=l2, method='createrune', params={'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']]},
|
||||
description=['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:',
|
||||
'',
|
||||
'- 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'])
|
||||
update_example(node=l2, method='commando-listrunes', params={'rune': rune_l23['rune']})
|
||||
update_example(node=l2, method='commando-listrunes', params={})
|
||||
commando_res1 = update_example(node=l1, method='commando', params={'peer_id': l2.info['id'], 'rune': rune_l21['rune'], 'method': 'newaddr', 'params': {'addresstype': 'p2tr'}})
|
||||
|
@ -799,6 +812,19 @@ def generate_runes_examples(l1, l2, l3):
|
|||
update_example(node=l1, method='commando-rune', params={'restrictions': [[f'id={l1.info["id"]}'], ['method=listpeers'], ['pnum=1'], [f'pnameid={l1.info["id"]}', f'parr0={l1.info["id"]}']]}, description=["Let's create a rune which lets a specific peer run listpeers on themselves:"])
|
||||
rune_l15 = update_example(node=l1, method='commando-rune', params={'restrictions': [[f'id={l1.info["id"]}'], ['method=listpeers'], ['pnum=1'], [f'pnameid^{trimmed_id}', f'parr0^{trimmed_id}']]}, description=["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:"])
|
||||
update_example(node=l1, method='commando-rune', params=[rune_l15['rune'], [['time<"$(($(date +%s) + 24*60*60))"', 'rate=2']]], description=["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:"])
|
||||
update_example(node=l1, method='commando-rune', params={'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']]},
|
||||
description=['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:',
|
||||
'',
|
||||
'- 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'])
|
||||
REPLACE_RESPONSE_VALUES.extend([
|
||||
{'data_keys': ['last_used'], 'original_value': showrunes_res1['runes'][0]['last_used'], 'new_value': NEW_VALUES_LIST['time_at_800']},
|
||||
{'data_keys': ['last_used'], 'original_value': showrunes_res2['runes'][1]['last_used'], 'new_value': NEW_VALUES_LIST['time_at_800']},
|
||||
|
|
|
@ -7,8 +7,8 @@ import json
|
|||
import re
|
||||
|
||||
# To maintain the sequence of the before return value (body) and after return value (footer) sections in the markdown file
|
||||
BODY_KEY_SEQUENCE = ['reliability', 'usage', 'restriction_format', 'permitted_sqlite3_functions', 'treatment_of_types', 'tables', 'notes', 'notifications', 'sharing_runes', 'riskfactor_effect_on_routing', 'recommended_riskfactor_values', 'optimality', 'randomization']
|
||||
FOOTER_KEY_SEQUENCE = ['errors', 'trivia', 'author', 'see_also', 'resources', 'example_notifications', 'examples']
|
||||
BODY_KEY_SEQUENCE = ['reliability', 'restriction_format', 'permitted_sqlite3_functions', 'treatment_of_types', 'tables', 'notes', 'notifications', 'sharing_runes', 'riskfactor_effect_on_routing', 'recommended_riskfactor_values', 'optimality', 'randomization']
|
||||
FOOTER_KEY_SEQUENCE = ['errors', 'trivia', 'author', 'see_also', 'resources', 'usage', 'example_notifications', 'examples']
|
||||
|
||||
|
||||
def output_title(title, underline='-', num_leading_newlines=1, num_trailing_newlines=2):
|
||||
|
@ -82,7 +82,7 @@ def output_conditional_params(conditional_sub_array, condition):
|
|||
# Join all keys with the separator
|
||||
keysfoundstr = format(esc_underscores(separator.join(conditional_sub_array)))
|
||||
# Print the merged keys
|
||||
output('{}{}'.format(fmt_paramname(keysfoundstr, True, False), '' if condition == 'dependentUpon' else ' '))
|
||||
output('{}'.format(fmt_paramname(keysfoundstr, True, condition != 'dependentUpon')))
|
||||
|
||||
|
||||
def output_type(properties, is_optional):
|
||||
|
@ -323,26 +323,6 @@ def create_shell_command(rpc, example):
|
|||
output('```\n')
|
||||
|
||||
|
||||
def create_expandable(title, rpc, examples):
|
||||
"""Output example/s with request and response in collapsible header"""
|
||||
output('\n<details>\n')
|
||||
output('<summary>\n')
|
||||
output(f'<span style="font-size: 1.5em; font-weight: bold;">{title}</span><br>\n')
|
||||
output('</summary>\n\n')
|
||||
for i, example in enumerate(examples):
|
||||
output('{}**Example {}**: {}\n'.format('' if i == 0 else '\n', i + 1, '\n'.join(example.get('description', ''))))
|
||||
output('\nRequest:\n')
|
||||
create_shell_command(rpc, example)
|
||||
output('```json\n')
|
||||
output(json.dumps(example['request'], indent=2).strip() + '\n')
|
||||
output('```\n')
|
||||
output('\nResponse:\n')
|
||||
output('```json\n')
|
||||
output(json.dumps(example['response'], indent=2).strip() + '\n')
|
||||
output('```\n')
|
||||
output('</details>')
|
||||
|
||||
|
||||
def generate_header(schema):
|
||||
"""Generate lines for rpc title and synopsis with request parameters"""
|
||||
output_title(esc_underscores(''.join(['lightning-', schema['rpc'], ' -- ', schema['title']])), '=', 0, 1)
|
||||
|
@ -368,7 +348,7 @@ def generate_header(schema):
|
|||
output('{}*{}* '.format('' if 'required' in request and toplevels[i] in request['required'] else '[', esc_underscores(toplevels[i])))
|
||||
output_conditional_params(dependent_upon_obj[toplevels[i]], 'dependentUpon')
|
||||
toplevels = [key for key in toplevels if key not in dependent_upon_obj[toplevels[i]]]
|
||||
output('{}'.format('' if 'required' in request and toplevels[i] in request['required'] else ']'))
|
||||
output('{}'.format('' if 'required' in request and toplevels[i] in request['required'] else '] '))
|
||||
else:
|
||||
# Search for the parameter in any conditional sub-arrays (oneOfMany, pairedWith)
|
||||
condition, foundinsubarray = search_key_in_conditional_array(request, toplevels[i])
|
||||
|
@ -500,7 +480,18 @@ def generate_footer(schema):
|
|||
output(json.dumps(notification, indent=2).strip() + '\n')
|
||||
output('```')
|
||||
elif key == 'examples' and len(schema[key]) > 0:
|
||||
create_expandable('EXAMPLES', schema['rpc'], schema.get('examples', []))
|
||||
output_title(key.replace('_', ' ').upper(), '-', 1)
|
||||
for i, example in enumerate(schema.get('examples', [])):
|
||||
output('\n{}**Example {}**: {}\n'.format('' if i == 0 else '\n', i + 1, '\n'.join(example.get('description', ''))))
|
||||
output('\nRequest:\n')
|
||||
create_shell_command(schema['rpc'], example)
|
||||
output('```json\n')
|
||||
output(json.dumps(example['request'], indent=2).strip() + '\n')
|
||||
output('```\n')
|
||||
output('\nResponse:\n')
|
||||
output('```json\n')
|
||||
output(json.dumps(example['response'], indent=2).strip() + '\n')
|
||||
output('```')
|
||||
else:
|
||||
output_title(key.replace('_', ' ').upper(), '-', 1)
|
||||
outputs(schema[key], '\n')
|
||||
|
|
|
@ -17,7 +17,7 @@ TITLELINE="$(head -n1 "$SOURCE")"
|
|||
# because it is used in the examples to run it in the shell, eg. $(lightning-cli listpeerchannels)
|
||||
SOURCE=$(tail -n +3 "$SOURCE" | sed -E '
|
||||
:a;N;$!ba;
|
||||
s#\s*<details>\s*<summary>\s*<span style="font-size: 1\.5em; font-weight: bold;">EXAMPLES</span><br>\s*</summary>#\n\nEXAMPLES\n------------\n#g;
|
||||
s#EXAMPLES\n------------#\nEXAMPLES\n------------\n#g;
|
||||
s#Request:#Request:\n#g;
|
||||
s#Response:#Response:\n#g;
|
||||
s#(\(lightning-cli)#\x1#ig;
|
||||
|
|
Loading…
Add table
Reference in a new issue