forked from chrisguida/cln-plugin-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f6239be
Showing
23 changed files
with
2,548 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Beware! This file is rewritten by htop when settings are changed in the interface. | ||
# The parser is also very primitive, and not human-friendly. | ||
htop_version=3.2.1 | ||
config_reader_min_version=3 | ||
fields=0 48 17 18 38 39 40 2 46 47 49 1 | ||
hide_kernel_threads=1 | ||
hide_userland_threads=0 | ||
shadow_other_users=0 | ||
show_thread_names=0 | ||
show_program_path=1 | ||
highlight_base_name=0 | ||
highlight_deleted_exe=1 | ||
highlight_megabytes=1 | ||
highlight_threads=1 | ||
highlight_changes=0 | ||
highlight_changes_delay_secs=5 | ||
find_comm_in_cmdline=1 | ||
strip_exe_from_cmdline=1 | ||
show_merged_command=0 | ||
header_margin=1 | ||
screen_tabs=1 | ||
detailed_cpu_time=0 | ||
cpu_count_from_one=0 | ||
show_cpu_usage=1 | ||
show_cpu_frequency=0 | ||
show_cpu_temperature=0 | ||
degree_fahrenheit=0 | ||
update_process_names=0 | ||
account_guest_in_cpu_meter=0 | ||
color_scheme=0 | ||
enable_mouse=1 | ||
delay=15 | ||
hide_function_bar=0 | ||
header_layout=two_50_50 | ||
column_meters_0=LeftCPUs2 Memory Swap | ||
column_meter_modes_0=1 1 1 | ||
column_meters_1=RightCPUs2 Tasks LoadAverage Uptime | ||
column_meter_modes_1=1 2 2 2 | ||
tree_view=0 | ||
sort_key=46 | ||
tree_sort_key=0 | ||
sort_direction=-1 | ||
tree_sort_direction=1 | ||
tree_view_always_by_pid=0 | ||
all_branches_collapsed=0 | ||
screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command | ||
.sort_key=PERCENT_CPU | ||
.tree_sort_key=PID | ||
.tree_view=0 | ||
.tree_view_always_by_pid=0 | ||
.sort_direction=-1 | ||
.tree_sort_direction=1 | ||
.all_branches_collapsed=0 | ||
screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE | ||
.sort_key=IO_RATE | ||
.tree_sort_key=PID | ||
.tree_view=0 | ||
.tree_view_always_by_pid=0 | ||
.sort_direction=-1 | ||
.tree_sort_direction=1 | ||
.all_branches_collapsed=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[global] | ||
disable-pip-version-check = yes | ||
index-url = https://package-proxy.replit.com/pypi/simple/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[[tool.poetry.source]] | ||
name = "replit" | ||
url = "https://package-proxy.replit.com/pypi/simple/" | ||
default = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# The command that runs the program. If the interpreter field is set, it will have priority and this run command will do nothing | ||
run = "python3 main.py" | ||
|
||
# The primary language of the repl. There can be others, though! | ||
language = "python3" | ||
entrypoint = "helloworld.py" | ||
|
||
# A list of globs that specify which files and directories should | ||
# be hidden in the workspace. | ||
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"] | ||
|
||
# Specifies which nix channel to use when building the environment. | ||
[nix] | ||
channel = "stable-22_11" | ||
|
||
# The command to start the interpreter. | ||
[interpreter] | ||
[interpreter.command] | ||
args = [ | ||
"stderred", | ||
"--", | ||
"prybar-python310", | ||
"-q", | ||
"--ps1", | ||
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ", | ||
"-i", | ||
] | ||
env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" } | ||
|
||
[env] | ||
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv" | ||
PATH = "${VIRTUAL_ENV}/bin" | ||
PYTHONPATH = "$PYTHONHOME/lib/python3.10:${VIRTUAL_ENV}/lib/python3.10/site-packages" | ||
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/" | ||
MPLBACKEND = "TkAgg" | ||
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry" | ||
|
||
# Enable unit tests. This is only supported for a few languages. | ||
[unitTest] | ||
language = "python3" | ||
|
||
# Add a debugger! | ||
[debugger] | ||
support = true | ||
|
||
# How to start the debugger. | ||
[debugger.interactive] | ||
transport = "localhost:0" | ||
startCommand = ["dap-python", "main.py"] | ||
|
||
# How to communicate with the debugger. | ||
[debugger.interactive.integratedAdapter] | ||
dapTcpAddress = "localhost:0" | ||
|
||
# How to tell the debugger to start a debugging session. | ||
[debugger.interactive.initializeMessage] | ||
command = "initialize" | ||
type = "request" | ||
|
||
[debugger.interactive.initializeMessage.arguments] | ||
adapterID = "debugpy" | ||
clientID = "replit" | ||
clientName = "replit.com" | ||
columnsStartAt1 = true | ||
linesStartAt1 = true | ||
locale = "en-us" | ||
pathFormat = "path" | ||
supportsInvalidatedEvent = true | ||
supportsProgressReporting = true | ||
supportsRunInTerminalRequest = true | ||
supportsVariablePaging = true | ||
supportsVariableType = true | ||
|
||
# How to tell the debugger to start the debuggee application. | ||
[debugger.interactive.launchMessage] | ||
command = "attach" | ||
type = "request" | ||
|
||
[debugger.interactive.launchMessage.arguments] | ||
logging = {} | ||
|
||
# Configures the packager. | ||
[packager] | ||
language = "python3" | ||
ignoredPackages = ["unit_tests"] | ||
|
||
[packager.features] | ||
enabledForHosting = false | ||
# Enable searching packages from the sidebar. | ||
packageSearch = true | ||
# Enable guessing what packages are needed from the code. | ||
guessImports = true | ||
|
||
# These are the files that need to be preserved when this | ||
# language template is used as the base language template | ||
# for Python repos imported from GitHub | ||
[gitHubImport] | ||
requiredFiles = [".replit", "replit.nix", ".config", "venv"] | ||
|
||
[languages] | ||
|
||
[languages.python3] | ||
pattern = "**/*.py" | ||
|
||
[languages.python3.languageServer] | ||
start = "pylsp" | ||
|
||
[deployment] | ||
run = ["sh", "-c", "python3 main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Writing Your First CLN Plugin | ||
|
||
Speaker: Chris Guida<br> | ||
Twitter: @cguida6 | ||
|
||
Welcome! In this tutorial, you'll write your own CLN plugin! To help you get started as fast as possible, we've put together a repl.it environment with Bitcoin Core (`bitcoind`) and Core Lightning (`lightningd`) already installed. So all you need to do is read through each section and follow the examples, and at the end you'll have a working CLN plugin. | ||
|
||
## Session Agenda: | ||
- Build a minimal python plugin | ||
- An init method | ||
- An RPC method | ||
- An option | ||
- An event subscription | ||
- A hook | ||
- Then we'll look at more complex plugins | ||
- Python: Sauron, Summary | ||
- Go: Peerswap, Circular | ||
- Rust: Watchtower, Hodlvoice | ||
|
||
## What's in this Repl? | ||
- `bitcoind`: you'll use this as your blockchain backend in regtest mode to test your plugin | ||
- `lightningd`: a full, functional install of CLN suitable for testing your plugin | ||
- `lightning`: clone of [the official CLN repo](https://github.com/ElementsProject/lightning) | ||
- `plugins`: clone of [the official CLN plugins repo](https://github.com/lightningd/plugins) | ||
|
||
## Chris's Hackathon Plugin Ideas He Could Help You With: | ||
|
||
1. (Easy) Implement an RPC method as a CLI tool that reports various stats about your node. | ||
2. (Medium) Port any plugin to a different language. Python tends to be slower and more bloated than other languages, so Rust and Go can really help to slim things down and speed them up. | ||
3. (Hard) Add support for trampoline routing between liquid and normal lightning network. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# What is a plugin anyway? | ||
- Executable file | ||
- Started by CLN | ||
- Runs as a subprocess of CLN | ||
- Communicates with CLN via the plugin’s stdin and stdout | ||
- Can be written in any language | ||
- Can be launched at CLN startup or dynamically launched | ||
- Extends CLN’s functionality via: | ||
- RPC methods | ||
- Event stream notifications | ||
- Hooks | ||
|
||
In this tutorial, we'll look at each of these elements more closely. | ||
|
||
## Examples of plugins | ||
|
||
### [Built in plugins](https://github.com/ElementsProject/lightning/tree/master/plugins): | ||
- Pay (pays invoices) | ||
- Bcli (connects to a bitcoin backend) | ||
- Keysend (aids in sending and receiving keysend payments) | ||
- Bookkeeper (accounting manager) | ||
|
||
### [Official plugins repo](https://github.com/lightningd/plugins) | ||
- Summary (Print a nice summary of the node status) | ||
- Circular (A smart rebalancing plugin for Core Lightning routing nodes) | ||
- Watchtower (Watchtower client for The Eye of Satoshi) | ||
- Sauron (A Bitcoin backend relying on Esplora's API) | ||
- Reckless (An experimental plugin manager) | ||
|
||
### Other | ||
- [CLBOSS](https://github.com/ZmnSCPxj/clboss) (Automated node manager) | ||
|
||
## Languages and Frameworks | ||
### Python | ||
- [pyln-client](https://github.com/ElementsProject/lightning/tree/master/contrib/pyln-client) by @cdecker | ||
</br> | ||
</br> | ||
|
||
### Rust | ||
- [cln-plugin](https://github.com/ElementsProject/lightning/blob/master/plugins) by @cdecker | ||
</br> | ||
</br> | ||
|
||
### Go | ||
- [glightning](https://github.com/niftynei/glightning) by @niftynei | ||
</br> | ||
</br> | ||
|
||
### C | ||
- [libplugin](https://github.com/ElementsProject/lightning/blob/master/plugins/libplugin.h) by @rustyrussell | ||
</br> | ||
</br> | ||
|
||
### C++ | ||
- [lightning-cpp](https://github.com/darosior/lightningcpp) by @darosior | ||
</br> | ||
</br> | ||
|
||
### Javascript | ||
- [clightningjs](https://github.com/lightningd/clightningjs) by @darosior | ||
</br> | ||
</br> | ||
|
||
### Typescript | ||
- [core-ln.ts](https://github.com/runcitadel/core-ln.ts) by @AaronDewes | ||
</br> | ||
</br> | ||
|
||
### Java | ||
- [JRPClightning](https://github.com/clightning4j/JRPClightning) by @vincenzopalazzo | ||
</br> | ||
</br> | ||
|
||
### C# | ||
- [DotNetLightning](https://github.com/joemphilips/DotNetLightning) by @joemphilips | ||
</br> | ||
</br> | ||
|
||
### Kotlin | ||
- [Tutorial/example using JRPClightning Java Framework](https://vincenzopalazzo.medium.com/a-day-in-a-c-lightning-plugin-with-koltin-c8bbd4fa0406) by @vincenzopalazzo | ||
</br> | ||
</br> |
Oops, something went wrong.