• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H03-Nov-2021-789702

bitcoin/H03-Nov-2021-6,8374,814

ccan/H03-Nov-2021-102,72483,548

channeld/H03-Nov-2021-9,0736,261

cli/H03-Nov-2021-1,5041,174

closingd/H03-Nov-2021-1,232939

common/H03-Nov-2021-34,91724,232

connectd/H03-Nov-2021-5,8683,787

contrib/H03-Nov-2021-23,37718,429

devtools/H03-Nov-2021-5,6524,629

doc/H03-May-2022-23,76219,557

external/H03-May-2022-164,194128,371

gossipd/H03-Nov-2021-9,8716,953

hsmd/H03-Nov-2021-2,7851,781

lightningd/H03-Nov-2021-39,57629,299

onchaind/H03-Nov-2021-5,4253,796

openingd/H03-Nov-2021-6,2324,273

plugins/H03-Nov-2021-24,09117,671

tests/H03-Nov-2021-26,73717,741

tools/H03-Nov-2021-3,9813,131

wallet/H03-Nov-2021-14,79511,063

wire/H03-Nov-2021-4,4693,560

.clang-formatH A D03-Nov-2021141 76

.dir-locals.elH A D03-Nov-2021193 87

.editorconfigH A D03-Nov-2021316 2216

.gitattributesH A D03-Nov-2021483 1513

.gitignoreH A D03-Nov-2021946 6158

.gitlab-ci.ymlH A D03-Nov-20211.4 KiB3933

.gitmodulesH A D03-Nov-2021665 2019

CHANGELOG.mdH A D03-Nov-2021115 KiB1,5411,252

DockerfileH A D03-Nov-20214.3 KiB10585

LICENSEH A D03-Nov-20211.2 KiB2318

MakefileH A D03-May-202232.8 KiB868651

README.mdH A D03-Nov-202111.5 KiB246176

action.ymlH A D03-Nov-2021161 76

ccan_compat.hH A D03-Nov-20211,002 2017

configureH A D03-Nov-202112.6 KiB451373

requirements.lockH A D03-Nov-20213.4 KiB186184

README.md

1# c-lightning: A specification compliant Lightning Network implementation in C
2
3c-lightning is a lightweight, highly customizable and [standard compliant][std] implementation of the Lightning Network protocol.
4
5* [Getting Started](#getting-started)
6    * [Installation](#installation)
7    * [Starting lightningd](#starting-lightningd)
8    * [Using the JSON-RPC Interface](#using-the-json-rpc-interface)
9    * [Care And Feeding Of Your New Lightning Node](#care-and-feeding-of-your-new-lightning-node)
10    * [Opening A Channel](#opening-a-channel)
11	* [Sending and Receiving Payments](#sending-and-receiving-payments)
12	* [Configuration File](#configuration-file)
13* [Further Information](#further-information)
14    * [FAQ](doc/FAQ.md)
15    * [Pruning](#pruning)
16    * [HD wallet encryption](#hd-wallet-encryption)
17	* [Developers](#developers)
18* [Documentation](https://lightning.readthedocs.io/)
19
20## Project Status
21
22[![Continuous Integration](https://github.com/ElementsProject/lightning/workflows/Continuous%20Integration/badge.svg)][actions]
23[![Pull Requests Welcome][prs]][prs-link]
24[![Irc][IRC]][IRC-link]
25[![Documentation Status](https://readthedocs.org/projects/lightning/badge/?version=docs)][docs]
26
27This implementation has been in production use on the Bitcoin mainnet since early 2018, with the launch of the [Blockstream Store][blockstream-store-blog].
28We recommend getting started by experimenting on `testnet` (or `regtest`), but the implementation is considered stable and can be safely used on mainnet.
29
30Any help testing the implementation, reporting bugs, or helping with outstanding issues is very welcome.
31Don'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].
32
33## Getting Started
34
35c-lightning only works on Linux and Mac OS, and requires a locally (or remotely) running `bitcoind` (version 0.16 or above) that is fully caught up with the network you're running on, and relays transactions (ie with `blocksonly=0`).
36Pruning (`prune=n` option in `bitcoin.conf`) is partially supported, see [here](#pruning) for more details.
37
38### Installation
39
40There are 4 supported installation options:
41
42 - Installation from the [Ubuntu PPA][ppa].
43 - Installation of a pre-compiled binary from the [release page][releases] on Github.
44 - Using one of the [provided docker images][dockerhub] on the Docker Hub.
45 - Compiling the source code yourself as described in the [installation documentation](doc/INSTALL.md).
46
47For the impatient here's the gist of it for Ubuntu:
48
49```bash
50sudo apt-get install -y software-properties-common
51sudo add-apt-repository -u ppa:lightningnetwork/ppa
52sudo apt-get install lightningd snapd
53sudo snap install bitcoin-core
54sudo ln -s /snap/bitcoin-core/current/bin/bitcoin{d,-cli} /usr/local/bin/
55```
56
57### Starting `lightningd`
58
59#### Regtest (local, fast-start) Option
60If you want to experiment with `lightningd`, there's a script to set
61up a `bitcoind` regtest test network of two local lightning nodes,
62which provides a convenient `start_ln` helper. See the notes at the top
63of the `startup_regtest.sh` file for details on how to use it.
64
65```bash
66. contrib/startup_regtest.sh
67```
68
69Note that your local nodeset will be much faster/more responsive if
70you've configured your node to expose the developer options, e.g.
71
72```bash
73./configure --enable-developer
74```
75
76#### Mainnet Option
77To test with real bitcoin,  you will need to have a local `bitcoind` node running:
78
79```bash
80bitcoind -daemon
81```
82
83Wait until `bitcoind` has synchronized with the network.
84
85Make sure that you do not have `walletbroadcast=0` in your `~/.bitcoin/bitcoin.conf`, or you may run into trouble.
86Notice that running `lightningd` against a pruned node may cause some issues if not managed carefully, see [below](#pruning) for more information.
87
88You can start `lightningd` with the following command:
89
90```bash
91lightningd --network=bitcoin --log-level=debug
92```
93
94This creates a `.lightning/` subdirectory in your home directory: see `man -l doc/lightningd.8` (or https://lightning.readthedocs.io/) for more runtime options.
95
96### Using The JSON-RPC Interface
97
98c-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).
99
100You can use `lightning-cli help` to print a table of RPC methods; `lightning-cli help <command>`
101will offer specific information on that command.
102
103Useful commands:
104
105* [newaddr](doc/lightning-newaddr.7.md): get a bitcoin address to deposit funds into your lightning node.
106* [listfunds](doc/lightning-listfunds.7.md): see where your funds are.
107* [connect](doc/lightning-connect.7.md): connect to another lightning node.
108* [fundchannel](doc/lightning-fundchannel.7.md): create a channel to another connected node.
109* [invoice](doc/lightning-invoice.7.md): create an invoice to get paid by another node.
110* [pay](doc/lightning-pay.7.md): pay someone else's invoice.
111* [plugin](doc/lightning-plugin.7.md): commands to control extensions.
112
113### Care And Feeding Of Your New Lightning Node
114
115Once you've started for the first time, there's a script called
116`contrib/bootstrap-node.sh` which will connect you to other nodes on
117the lightning network.
118
119There are also numerous plugins available for c-lightning which add
120capabilities: in particular there's a collection at:
121
122	https://github.com/lightningd/plugins
123
124Including [helpme][helpme-github] which guides you through setting up
125your first channels and customizing your node.
126
127For a less reckless experience, you can encrypt the HD wallet seed:
128 see [HD wallet encryption](#hd-wallet-encryption).
129
130You can also chat to other users at [#c-lightning @ libera.chat][irc2];
131we are always happy to help you get started!
132
133
134### Opening A Channel
135
136First you need to transfer some funds to `lightningd` so that it can
137open a channel:
138
139```bash
140# Returns an address <address>
141lightning-cli newaddr
142```
143
144`lightningd` will register the funds once the transaction is confirmed.
145
146You may need to generate a p2sh-segwit address if the faucet does not support bech32:
147
148```bash
149# Return a p2sh-segwit address
150lightning-cli newaddr p2sh-segwit
151```
152
153Confirm `lightningd` got funds by:
154
155```bash
156# Returns an array of on-chain funds.
157lightning-cli listfunds
158```
159
160Once `lightningd` has funds, we can connect to a node and open a channel.
161Let's assume the **remote** node is accepting connections at `<ip>`
162(and optional `<port>`, if not 9735) and has the node ID `<node_id>`:
163
164```bash
165lightning-cli connect <node_id> <ip> [<port>]
166lightning-cli fundchannel <node_id> <amount_in_satoshis>
167```
168
169This opens a connection and, on top of that connection, then opens a channel.
170The funding transaction needs 3 confirmation in order for the channel to be usable, and 6 to be announced for others to use.
171You 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`.
172
173### Sending and Receiving Payments
174
175Payments in Lightning are invoice based.
176The recipient creates an invoice with the expected `<amount>` in
177millisatoshi (or `"any"` for a donation), a unique `<label>` and a
178`<description>` the payer will see:
179
180```bash
181lightning-cli invoice <amount> <label> <description>
182```
183
184This returns some internal details, and a standard invoice string called `bolt11` (named after the [BOLT #11 lightning spec][BOLT11]).
185
186[BOLT11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
187
188The sender can feed this `bolt11` string to the `decodepay` command to see what it is, and pay it simply using the `pay` command:
189
190```bash
191lightning-cli pay <bolt11>
192```
193
194Note that there are lower-level interfaces (and more options to these
195interfaces) for more sophisticated use.
196
197## Configuration File
198
199`lightningd` can be configured either by passing options via the command line, or via a configuration file.
200Command line options will always override the values in the configuration file.
201
202To use a configuration file, create a file named `config` within your top-level lightning directory or network subdirectory
203(eg. `~/.lightning/config` or `~/.lightning/bitcoin/config`).  See `man -l doc/lightningd-config.5`.
204
205## Further information
206
207### Pruning
208
209c-lightning requires JSON-RPC access to a fully synchronized `bitcoind` in order to synchronize with the Bitcoin network.
210Access to ZeroMQ is not required and `bitcoind` does not need to be run with `txindex` like other implementations.
211The lightning daemon will poll `bitcoind` for new blocks that it hasn't processed yet, thus synchronizing itself with `bitcoind`.
212If `bitcoind` prunes a block that c-lightning has not processed yet, e.g., c-lightning was not running for a prolonged period, then `bitcoind` will not be able to serve the missing blocks, hence c-lightning will not be able to synchronize anymore and will be stuck.
213In order to avoid this situation you should be monitoring the gap between c-lightning's blockheight using `lightning-cli getinfo` and `bitcoind`'s blockheight using `bitcoin-cli getblockchaininfo`.
214If the two blockheights drift apart it might be necessary to intervene.
215
216### HD wallet encryption
217
218You 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 `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 `hsmtool` with the `decrypt` method.
219
220If 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.
221
222### Developers
223
224Developers wishing to contribute should start with the developer guide [here](doc/HACKING.md).
225You should also configure with `--enable-developer` to get additional checks and options.
226
227[blockstream-store-blog]: https://blockstream.com/2018/01/16/en-lightning-charge/
228[std]: https://github.com/lightningnetwork/lightning-rfc
229[travis-ci]: https://travis-ci.org/ElementsProject/lightning.svg?branch=master
230[travis-ci-link]: https://travis-ci.org/ElementsProject/lightning
231[prs]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat
232[prs-link]: http://makeapullrequest.com
233[IRC]: https://img.shields.io/badge/chat-on%20libera-brightgreen.svg
234[IRC-link]: https://web.libera.chat/#c-lightning
235[irc1]: https://web.libera.chat/#lightning-dev
236[irc2]: https://web.libera.chat/#c-lightning
237[ml1]: https://lists.ozlabs.org/listinfo/c-lightning
238[ml2]: https://lists.linuxfoundation.org/mailman/listinfo/lightning-dev
239[docs]: https://lightning.readthedocs.org
240[ppa]: https://launchpad.net/~lightningnetwork/+archive/ubuntu/ppa
241[releases]: https://github.com/ElementsProject/lightning/releases
242[dockerhub]: https://hub.docker.com/r/elementsproject/lightningd/
243[jsonrpcspec]: https://www.jsonrpc.org/specification
244[helpme-github]: https://github.com/lightningd/plugins/tree/master/helpme
245[actions]: https://github.com/ElementsProject/lightning/actions
246