Core Lightning — Lightning Network implementation focusing on spec compliance and performance
  • C 67%
  • Python 25.7%
  • Rust 5.3%
  • Makefile 0.8%
  • Assembly 0.6%
  • Other 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
daywalker90 7faac86fc1 tests: fixe test_multichan_stress flake
```
         def send_many_payments():
             passes = 0
             fails = 0
             # Make sure we try many times, and get at least one pass and fail.
             while passes == 0 or fails == 0 or passes + fails < 30:
                 inv = l3.rpc.invoice(100, "label-" + str(passes + fails), "desc")
                 l1.rpc.sendpay(route, inv['payment_hash'], payment_secret=inv['payment_secret'])
                 time.sleep(0.05)
                 try:
                     l1.rpc.waitsendpay(inv['payment_hash'])
                     passes += 1
                 except RpcError:
                     fails += 1
                     pass

         # Send a heap of payments, while reconnecting...
         fut = executor.submit(send_many_payments)

         for _ in range(30):
             l3.rpc.disconnect(l2.info['id'], force=True)
             time.sleep(0.1)
             l3.rpc.connect(l2.info['id'], 'localhost', l2.port)
 >       fut.result(TIMEOUT)
```

The while loop would somtimes go infinitely long if no payments fail.

Changelog-None
2026-08-11 17:39:13 +02:00
.github CI: add concurrency restrictions for macos and msrv workflows 2026-08-06 20:32:41 +02:00
bitcoin common: add helpers for bitcoin blockids. 2026-05-11 15:51:05 +09:30
ccan ccan: update ccan to fe99a8e0 2026-07-07 11:42:55 +10:00
channeld channeld: reject closing_complete and closing_sig with a clear error 2026-07-02 13:30:17 -03:00
cli cli: remove \ in simple format. 2026-03-23 14:03:17 +10:00
cln-grpc askrene: add APIs for "impressions" which are *relative* constraints. 2026-08-04 18:51:43 -03:00
cln-rpc askrene: add APIs for "impressions" which are *relative* constraints. 2026-08-04 18:51:43 -03:00
closingd simpleclosed.c: add heuristic to delay our tx broadcast if our amount is less AND our fee is less than our peer's amount and fee 2026-07-02 13:30:17 -03:00
common askrene: give clearer error codes. 2026-08-04 18:51:43 -03:00
connectd connectd: handle an already-connected subd gracefully 2026-07-16 16:47:57 +02:00
contrib offers: limit invoices to 10 minutes for recurring offers in other currencies. 2026-08-04 18:51:43 -03:00
db lightningd: add watchman storage and persistence skeleton 2026-06-11 00:31:54 +10:00
devtools devtools: add --markdown output to credit for release notes 2026-06-30 14:53:00 +10:00
doc Revert "doc: require Homebrew GNU make and gpatch on macOS" 2026-08-05 15:26:49 +09:30
external wally: update libwally to v1.5.6 2026-08-03 09:52:43 +02:00
gossipd wire/splice: rename messages and TLV fields per updated BOLTs 2026-06-19 09:38:06 +09:30
hsmd BOLTs: more textual changes. 2026-04-30 20:09:31 +09:30
lightningd lightningd: parent watchman's formatted blockhash strings to tmpctx 2026-08-07 15:20:17 +10:00
nix nix: fix nix build and simplify NixOS install docs 2026-07-21 17:09:33 +02:00
onchaind common: add randbytes() wrapper to override cryptographic entropy: $CLN_DEV_ENTROPY_SEED 2026-07-13 18:15:06 -07:00
openingd dualopend: fix next_funding reconnect: error if both set it, tx_abort if only peer 2026-06-19 09:38:06 +09:30
plugins fetchinvoice: handle weird labels in recurrence_label parameter. 2026-08-04 18:51:43 -03:00
tests tests: fixe test_multichan_stress flake 2026-08-11 17:39:13 +02:00
tools downgrade tool: fix invalid memory bug 2026-08-04 18:51:43 -03:00
wallet add a test for downgrading askrene datastore 2026-08-04 18:51:43 -03:00
wire common: add randbytes() wrapper to override cryptographic entropy: $CLN_DEV_ENTROPY_SEED 2026-07-13 18:15:06 -07:00
.clang-format tools: Added .clang-format for formatting 2018-11-29 23:01:11 +00:00
.codespellignore devtools: Add codespell to pre-commit. 2026-01-24 09:40:49 +10:00
.codespellrc devtools: Add codespell to pre-commit. 2026-01-24 09:40:49 +10:00
.dir-locals.el emacs: add .dir-locals.el for linux style C 2018-01-10 04:01:56 +00:00
.dockerignore CI: remove focal and add resolute Ubuntu builds 2026-05-28 08:31:55 +02:00
.editorconfig Travis is no longer used 2022-04-07 06:54:02 +09:30
.gitattributes git: correctly mark contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py for binary diffs. 2026-01-20 19:32:42 +10:30
.gitignore CI: remove focal and add resolute Ubuntu builds 2026-05-28 08:31:55 +02:00
.gitlab-ci.yml Gitlab: updating outdated references 2023-05-30 11:42:21 +00:00
.gitmodules external/libsodium: remove 2025-10-26 20:31:45 +10:30
.msggen.json askrene: add APIs for "impressions" which are *relative* constraints. 2026-08-04 18:51:43 -03:00
.pre-commit-config.yaml devtools: Set pre-commit default versions for Python and NodeJS. 2026-01-24 09:40:49 +10:00
.version release: CHANGELOG and version bumps for v26.06.6 2026-07-21 11:49:51 +02:00
Cargo.lock crates: update dependencies and upgrade quick-xml, tower-http, and tokio-tungstenite 2026-07-14 11:16:17 +02:00
Cargo.toml crates: bump cln-rpc, cln-grpc and cln-plugin to v0.7.0 for release 2026-05-25 17:32:59 +02:00
ccan_compat.h ccan: rename ripemd160 functions 2023-07-10 14:56:50 +09:30
CHANGELOG.md release: CHANGELOG and version bumps for v26.06.6 2026-07-21 11:49:51 +02:00
codecov.yml Add comprehensive coverage infrastructure with clang source-based coverage 2025-12-08 16:37:02 +01:00
commitlint.config.js devtools: Add commitlint to pre-commit. 2026-01-24 09:40:49 +10:00
configure configure: remove -c to link test for macOS 2026-06-19 10:22:10 -03:00
conftest.py feat: Enhance JUnit XML reporting with environment variables and add import to conftest.py 2026-02-02 11:41:09 +01:00
DEV.md DEV.md: cheat sheet for developers and LLMs. 2026-06-17 02:22:02 +10:00
Dockerfile Dockerfile: add protobuf-compiler for vls signer step 2026-07-30 13:24:36 +02:00
flake.lock chore: nix flake update 2025-11-13 15:35:51 +10:30
flake.nix chore: nix flake update 2025-11-13 15:35:51 +10:30
LICENSE Update LICENSE 2024-01-31 13:33:30 +01:00
Makefile make: skip extract-bolt-csv if bolts are absent 2026-08-11 14:05:38 +02:00
mkdocs.yml lightningd: remove decodepay. 2026-01-20 19:32:42 +10:30
pyproject.toml python: upgrade min python version to 3.10 2026-04-20 14:09:03 +02:00
README.md Add Blockstream info and badge in README 2026-07-01 15:53:11 +09:30
SECURITY.md security: sync both security policy files 2026-06-24 20:16:02 +09:30
Taskfile.yml chore: Ensure the logging library does not get upset when output capture is disabled. 2026-01-20 15:05:07 +10:30
uv.lock release: CHANGELOG and version bumps for v26.06.6 2026-07-21 11:49:51 +02:00

Core Lightning (CLN): A specification compliant Lightning Network implementation in C

Core Lightning (previously c-lightning) is a lightweight, highly customizable and standard compliant implementation of the Lightning Network protocol, developed and maintained by Blockstream. Learn more about Blockstream's Lightning Network updates at blockstream.com/lightning.

Project Status

Continuous Integration Pull Requests Welcome Documentation Status Blockstream Telegram Discord Irc

This implementation has been in production use on the Bitcoin mainnet since early 2018, with the launch of the Blockstream Store. We recommend getting started by experimenting on testnet (testnet4 or regtest), but the implementation is considered stable and can be safely used on mainnet.

Reach Out to Us

Any help testing the implementation, reporting bugs, or helping with outstanding issues is very welcome. Don't hesitate to reach out to us on the implementation-specific mailing list, or on CLN Discord, or on CLN Telegram, or on IRC at dev/gen channel.

Getting Started

Core Lightning only works on Linux and macOS, and requires a locally (or remotely) running bitcoind (version 25.0 or above) that is fully caught up with the network you're running on, and relays transactions (ie with blocksonly=0). Pruning (prune=n option in bitcoin.conf) is partially supported, see here for more details.

Installation

There are 3 supported installation options:

Starting lightningd

Regtest (local, fast-start) Option

If you want to experiment with lightningd, there's a script to set up a bitcoind regtest test network of two local lightning nodes, which provides a convenient start_ln helper. See the notes at the top of the startup_regtest.sh file for details on how to use it.

. contrib/startup_regtest.sh

Mainnet Option

To test with real bitcoin, you will need to have a local bitcoind node running:

bitcoind -daemon

Wait until bitcoind has synchronized with the network.

Make sure that you do not have walletbroadcast=0 in your ~/.bitcoin/bitcoin.conf, or you may run into trouble. Notice that running lightningd against a pruned node may cause some issues if not managed carefully, see below for more information.

You can start lightningd with the following command:

lightningd --network=bitcoin --log-level=debug

This creates a .lightning/ subdirectory in your home directory: see man -l doc/lightningd.8 (or https://docs.corelightning.org/docs) for more runtime options.

Using The JSON-RPC Interface

Core Lightning exposes a JSON-RPC 2.0 interface over a Unix Domain socket; the lightning-cli tool can be used to access it, or there is a python client library.

You can use lightning-cli help to print a table of RPC methods; lightning-cli help <command> will offer specific information on that command.

Useful commands:

  • newaddr: get a bitcoin address to deposit funds into your lightning node.
  • listfunds: see where your funds are.
  • connect: connect to another lightning node.
  • fundchannel: create a channel to another connected node.
  • invoice: create an invoice to get paid by another node.
  • pay: pay someone else's invoice.
  • plugin: commands to control extensions.

Care And Feeding Of Your New Lightning Node

Once you've started for the first time, there's a script called contrib/bootstrap-node.sh which will connect you to other nodes on the lightning network.

There are also numerous plugins available for Core Lightning which add capabilities: in particular there's a collection at: https://github.com/lightningd/plugins

For a less reckless experience, you can encrypt the HD wallet seed: see HD wallet encryption.

You can also chat to other users at Discord core-lightning; we are always happy to help you get started!

Opening A Channel

First you need to transfer some funds to lightningd so that it can open a channel:

# Returns an address <address>
lightning-cli newaddr

lightningd will register the funds once the transaction is confirmed.

Alternatively you can generate a taproot address should your source of funds support it:

# Return a taproot address
lightning-cli newaddr p2tr

Confirm lightningd got funds by:

# Returns an array of on-chain funds.
lightning-cli listfunds

Once lightningd has funds, we can connect to a node and open a channel. Let's assume the remote node is accepting connections at <ip> (and optional <port>, if not 9735) and has the node ID <node_id>:

lightning-cli connect <node_id> <ip> [<port>]
lightning-cli fundchannel <node_id> <amount_in_satoshis>

This opens a connection and, on top of that connection, then opens a channel. The funding transaction needs 3 confirmation in order for the channel to be usable, and 6 to be announced for others to use. You can check the status of the channel using lightning-cli listpeers, which after 3 confirmations (1 on testnet) should say that state is CHANNELD_NORMAL; after 6 confirmations you can use lightning-cli listchannels to verify that the public field is now true.

Sending and Receiving Payments

Payments in Lightning are invoice based. The recipient creates an invoice with the expected <amount> in millisatoshi (or "any" for a donation), a unique <label> and a <description> the payer will see:

lightning-cli invoice <amount> <label> <description>

This returns some internal details, and a standard invoice string called bolt11 (named after the BOLT #11 lightning spec).

The sender can feed this bolt11 string to the decode command to see what it is, and pay it simply using the pay command:

lightning-cli pay <bolt11>

Note that there are lower-level interfaces (and more options to these interfaces) for more sophisticated use.

Configuration File

lightningd can be configured either by passing options via the command line, or via a configuration file. Command line options will always override the values in the configuration file.

To use a configuration file, create a file named config within your top-level lightning directory or network subdirectory (eg. ~/.lightning/config or ~/.lightning/bitcoin/config). See man -l doc/lightningd-config.5.

A sample configuration file is available at contrib/config-example.

Further information

Pruning

Core Lightning requires JSON-RPC access to a fully synchronized bitcoind in order to synchronize with the Bitcoin network. Access to ZeroMQ is not required and bitcoind does not need to be run with txindex like other implementations. The lightning daemon will poll bitcoind for new blocks that it hasn't processed yet, thus synchronizing itself with bitcoind. If bitcoind prunes a block that Core Lightning has not processed yet, e.g., Core Lightning was not running for a prolonged period, then bitcoind will not be able to serve the missing blocks, hence Core Lightning will not be able to synchronize anymore and will be stuck. In order to avoid this situation you should be monitoring the gap between Core Lightning's blockheight using lightning-cli getinfo and bitcoind's blockheight using bitcoin-cli getblockchaininfo. If the two blockheights drift apart it might be necessary to intervene.

HD wallet encryption

You can encrypt the hsm_secret content (which is used to derive the HD wallet's master key) by passing the --encrypted-hsm startup argument, or by using the lightning-hsmtool (which you can find in the tool/ directory at the root of this repo) with the encrypt method. You can unencrypt an encrypted hsm_secret using the lightning-hsmtool with the decrypt method.

If you encrypt your hsm_secret, you will have to pass the --encrypted-hsm startup option to lightningd. Once your hsm_secret is encrypted, you will not be able to access your funds without your password, so please beware with your password management. Also, beware of not feeling too safe with an encrypted hsm_secret: unlike for bitcoind where the wallet encryption can restrict the usage of some RPC command, lightningd always needs to access keys from the wallet which is thus not locked (yet), even with an encrypted BIP32 master seed.

Developers

Developers wishing to contribute should start with the developer guide here.