# Core Lightning (CLN): A specification compliant Lightning Network implementation in C Core Lightning (previously c-lightning) is a lightweight, highly customizable and [standard compliant][std] implementation of the Lightning Network protocol. * [Getting Started](#getting-started) * [Installation](#installation) * [Starting lightningd](#starting-lightningd) * [Using the JSON-RPC Interface](#using-the-json-rpc-interface) * [Care And Feeding Of Your New Lightning Node](#care-and-feeding-of-your-new-lightning-node) * [Opening A Channel](#opening-a-channel) * [Sending and Receiving Payments](#sending-and-receiving-payments) * [Configuration File](#configuration-file) * [Further Information](#further-information) * [FAQ](doc/FAQ.md) * [Pruning](#pruning) * [HD wallet encryption](#hd-wallet-encryption) * [Developers](#developers) * [Documentation](https://docs.corelightning.org/docs) ## Project Status [![Continuous Integration](https://github.com/ElementsProject/lightning/workflows/Continuous%20Integration/badge.svg)][actions] [![Pull Requests Welcome][prs]][prs-link] [![Irc][IRC]][IRC-link] [![Documentation Status](https://readthedocs.org/projects/lightning/badge/?version=docs)][docs] This implementation has been in production use on the Bitcoin mainnet since early 2018, with the launch of the [Blockstream Store][blockstream-store-blog]. We recommend getting started by experimenting on `testnet` (or `regtest`), but the implementation is considered stable and can be safely used on mainnet. Any help testing the implementation, reporting bugs, or helping with outstanding issues is very welcome. Don't hesitate to reach out to us on IRC at [#lightning-dev @ libera.chat][irc1], [#c-lightning @ libera.chat][irc2], or on the implementation-specific mailing list [c-lightning@lists.ozlabs.org][ml1], or on the Lightning Network-wide mailing list [lightning-dev@lists.linuxfoundation.org][ml2], or on Discord [core-lightning][discord], or on Telegram [Core Lightning][telegram]. ## Getting Started Core Lightning only works on Linux and macOS, and requires a locally (or remotely) running `bitcoind` (version 22.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](#pruning) for more details. ### Installation There are 4 supported installation options: - Installation of a pre-compiled binary from the [release page][releases] on GitHub. - Using one of the [provided docker images][dockerhub] on the Docker Hub. - Compiling the source code yourself as described in the [installation documentation](doc/getting-started/getting-started/installation.md). ### 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. ```bash . contrib/startup_regtest.sh ``` #### Mainnet Option To test with real bitcoin, you will need to have a local `bitcoind` node running: ```bash 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](#pruning) for more information. You can start `lightningd` with the following command: ```bash 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][jsonrpcspec] interface over a Unix Domain socket; the `lightning-cli` tool can be used to access it, or there is a [python client library](contrib/pyln-client). You can use `lightning-cli help` to print a table of RPC methods; `lightning-cli help ` will offer specific information on that command. Useful commands: * [newaddr](doc/lightning-newaddr.7.md): get a bitcoin address to deposit funds into your lightning node. * [listfunds](doc/lightning-listfunds.7.md): see where your funds are. * [connect](doc/lightning-connect.7.md): connect to another lightning node. * [fundchannel](doc/lightning-fundchannel.7.md): create a channel to another connected node. * [invoice](doc/lightning-invoice.7.md): create an invoice to get paid by another node. * [pay](doc/lightning-pay.7.md): pay someone else's invoice. * [plugin](doc/lightning-plugin.7.md): 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 Including [helpme][helpme-github] which guides you through setting up your first channels and customizing your node. For a less reckless experience, you can encrypt the HD wallet seed: see [HD wallet encryption](#hd-wallet-encryption). You can also chat to other users at [#c-lightning @ libera.chat][irc2]; 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: ```bash # Returns an address
lightning-cli newaddr ``` `lightningd` will register the funds once the transaction is confirmed. You may need to generate a p2sh-segwit address if the faucet does not support bech32: ```bash # Return a p2sh-segwit address lightning-cli newaddr p2sh-segwit ``` Confirm `lightningd` got funds by: ```bash # 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 `` (and optional ``, if not 9735) and has the node ID ``: ```bash lightning-cli connect [] lightning-cli fundchannel ``` 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 `` in millisatoshi (or `"any"` for a donation), a unique `