Interacting with your Core Lightning Node
Ok, you have a Rune and Node info and you've tested a CURL statement against the REST interface. Excellent!
But using curl statements are a little cumbersome. Maybe we can do better?
What if you want to interact with your node using a lightning-cli
-like interface? You're in luck! We wrote a bash script that translates your CLI requests into the corresponding curl statements. The result? An interactive terminal-like experience, all against your node's REST interface.
-k
option on lightning-cli
. We need key/value pairs so we can construct a JSON payload.Clone the Repo
This tool makes development much simpler since you can interact with your lightning node like you're at the terminal. To use this script, clone the repo:
git clone https://github.com/farscapian/lightning-cli-rest.git
Go look at the lightning-cli
file. It's just a simple bash script that parses your lightning-cli
commands and translates them into associated CURL statements which are executed against your CLN node's REST interface.
Execute a command against your CLN Node
Next, you can use the tool to make lightning-cli commands. For example:
./lightning-cli invoice -k amount_msat=100000 description="test" label="test1"
lightning-cli
, a .env
will get stubbed out. Go put your rune and REST endpoint in there to continue!Ok great! Make sure the command is returning valid responses before continuing. For example:
./lighting-cli getinfo
should yield something like:
{
"id": "0248820db560a5823949bf47af207e84f51a48a5d96288b338bc31c60a9b4efb4d",
"alias": "Alice",
"color": "ffffff",
"num_peers": 0,
"num_pending_channels": 0,
"num_active_channels": 0,
"num_inactive_channels": 0,
"address": [
{
"type": "dns",
"address": "cln-0",
"port": 9735
}
],
"binding": [
{
"type": "ipv4",
"address": "0.0.0.0",
"port": 9735
}
],
"version": "v23.11.2",
"blockheight": 14873,
"network": "regtest",
"fees_collected_msat": 0,
"lightning-dir": "/root/.lightning/regtest",
"our_features": {
"init": "08a0800a0a69a2",
"node": "88a0800a0a69a2",
"channel": "",
"invoice": "02000002024100"
}
}
Summary
At this point, you have a lightning-cli
you can use to interact with your node. Your nodes come pre-installed with a bunch of RPC methods already. But, if you want to add functionality to your Core Lightning node, you'll need to know about plugin development.
Getting Started
Developing your first CLN Plugin