# Reckless Design
## Tabele of Content
- Introduction
- Operation that need to be supported
- Requirements
- Current Draft
- Open question
- Evolution
## Introduction
https://docs.page/cln-reckless/reckless.rs#table-of-content
## Operation that need to be supportd
- Create the manifest if a plugin have no one;
- The manifest help to standardize the process of running an install the plugin, and
- Give the freedom to express a custom script to run/install the plugin (e.g: Java need a small trick to run it, and python need dep install and python version check before runnig the pluign).
- Install a plugin
- Search in the repository specified by the user, we could make a distinction with searching throug the releases and in the main branch if we want implement a safe pull (by pulling a release) or a reckless one by pulling and compile the current master.
- Download the plugin:
- Pull from repository in a .reckless dir
- compile in the dir, and all it is ok move it in the plugin dir (we avoid to messup the cln dir)
- Update a plugin:
- scroll the list of plugin installed, look in the manifest and compare what is in the manifest with what is in the master/release
## Requirements
- https://gist.github.com/rustyrussell/762297e84dc5239fe408c45e6811e1a9
### Technical:
- if first run, creates `~/.lightning/reckless/`, puts in empty `bitcoin.config` and `include ../reckless/bitcoin.config` if not already in `~/.lightning/bitcoin/config`
- download and unpack/move into `~/.lightning/reckless/<subdir>`
- perform simple check (e.g. for Python, you can run the plugin normally and it should exit with status 0).
- start up dynamically
- if it works, add to `reckless/bitcoin.config`
### Stretch goals:
- allow `--regtest / --testnet` and/or read default config to determine.
- follow `requirements.txt` for Python plugins
- support non-Python plugins
- allow them to contain reckless.config file:
- can require specific CLN versions
- can require other plugins
- can disable other plugins
- can specify non-dynamic (requires node restart to enable/disable)
- specify if config options are required (prompt user?)
- support `reckless upgrade [plugin-names...]` to d/l new plugin, test, and then replace.
- support `reckless list`
- support `reckless remove`
### Configuration format
What description language will be the best to describe all the use case that are described in the previous section?
- Plain Text, like core lightning but this will limite expression of list (list of disabled plugins) or object (configuration parameters required)
- JSON: required more work but it still works for case like this, and it is supported out of the box from all the language
```json
{
"name": "foo plugin",
"description": "Cool plugin",
"version": "v0.0.1-rc1",
"important": false,
"author": "Alibaba",
"license": "MIT",
"opts": [
{
"name": "foo",
"type": "str",
"def": "coffe machine",
"deprecated": false
}
],
"disable": [
"btcli"
],
"required": [],
"sys": {
"required": [
{
"dep_name": "python",
"version": "3.7",
}
],
"list_os": ["linux", "osx"]
"scripts": {
"install": "pip3 install -r requirements.txt",
"uninstall": "rm /rf $CLN_DIR/metrics"
}
},
"repository": []
}
```
Some of these filed are not necessary or not useful when we will go to code it.
There are many other like Yaml (space or tabl problem, but it is nice to define custom script), or Toml but I'm not confortable with it, I need to read the lang spec.
In addition, this file can be generated with `reckless --init .`
### Language implementation
- [ ] C
- [x] Rust
- I will not considerer python there just because we have better option, and release a binary can be always better imho, what do you think?
### Architecture proposal
This is was I start to build in rust, there is a nice dependeces management with cargo workspace, and we could build somethings like:
- `reckless_core`: all the logic to implement the commands of rackless and the action
- `reckless_cli`: a command line user interdace to perform the action based on `reckless_core`.
releasing `reckless_core` people can build cln plugin and also UI on top of it, usefult for work with UI app also.
## Current Draft
python: https://github.com/darosior/reckless
Rust: https://github.com/cln-reckless/reckless.rs
## Open question
- We want a command line or a plugin?
- I would like both, because a plugin can not cover all the case, and the command line too.
- We could also make reckless smarted and configure cln from a remote configuration by pulling conf file (reckless) or adding properties at runtime with the command line
## Evolution
- Create a plugin for devs from a template specifing `reckless create [--from <template>| --lang rust]`
- Push a plugin in one or more repository specified inside a manifest
- Expose a list of plugin with a web site generate by the github page + manifest information we can do similar to the pipy but less messy
- Provide a static API with github action + manifest to make the life easy from a plugin manager searching point of view.
## Appending
- Some community problem: https://www.reddit.com/r/lightningnetwork/comments/wzx71b/c_lightning_plugins_how_to_launch_and_configure/