You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ff0ee6d
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: doc/beginners-guide/beginners-guide.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,26 +11,24 @@ privacy:
11
11
#### Regtest (local, fast-start) option
12
12
13
13
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.
14
-
15
14
```bash
16
15
. contrib/startup_regtest.sh
17
16
```
18
17
19
18
#### Mainnet Option
20
19
21
-
To test with real bitcoin, you will need to have a local `bitcoind` node running:
22
-
20
+
To test with real bitcoin, you will need to have a local `bitcoind` node running:
23
21
```bash
24
22
bitcoind -daemon
25
23
```
26
24
27
25
Wait until `bitcoind` has synchronized with the network.
28
26
29
-
Make sure that you do not have `walletbroadcast=0` in your `~/.bitcoin/bitcoin.conf`, or you may run into trouble.
30
-
Notice that running `lightningd` against a pruned node may cause some issues if not managed carefully, see [pruning](doc:bitcoin-core##using-a-pruned-bitcoin-core-node) for more information.
27
+
Make sure that you do not have `walletbroadcast=0` in your `~/.bitcoin/bitcoin.conf`, or you may run into trouble.
31
28
32
-
You can start`lightningd`with the following command:
29
+
Notice that running`lightningd`against a pruned node may cause some issues if not managed carefully, see [pruning](doc:bitcoin-core#using-a-pruned-bitcoin-core-node) for more information.
33
30
31
+
You can start `lightningd` with the following command:
34
32
```bash
35
33
lightningd --network=bitcoin --log-level=debug
36
34
```
@@ -57,6 +55,6 @@ Useful commands:
57
55
58
56
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.
59
57
60
-
There are also numerous plugins available for Core Lightning which add capabilities: see the [Plugins](doc:plugins) guide, and check out the plugin collection at: <https://github.com/lightningd/plugins>.
58
+
There are also numerous plugins available for Core Lightning which add capabilities: see the [Plugins](doc:plugins) guide, and check out the plugin collection at: https://github.com/lightningd/plugins.
61
59
62
60
For a less reckless experience, you can encrypt the HD wallet seed: see [HD wallet encryption](doc:backup-and-recovery#hsm-secret-backup).
Copy file name to clipboardExpand all lines: doc/contribute-to-core-lightning/code-generation.md
+5-17Lines changed: 5 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ The CLN project has a multitude of interfaces, most of which are generated from
12
12
1. addition of FD passing semantics to allow establishing a new connection between daemons (communication uses [socketpair](https://man7.org/linux/man-pages/man2/socketpair.2.html), so no `connect`)
13
13
2. change the message length prefix from `u16` to `u32`, allowing for messages larger than 65Kb. The CSV files are with the respective sub-daemon and also use [generate-wire.py](https://github.com/ElementsProject/lightning/blob/master/tools/generate-wire.py) to generate encoding, decoding and printing functions
14
14
15
-
- We describe the JSON-RPC using [JSON Schema](https://json-schema.org/) in the [`doc/schemas`](https://github.com/ElementsProject/lightning/tree/master/doc/schemas) directory. Each method has a `lightning-*.json` for request and response. During tests the `pytest` target will verify responses, however the JSON-RPC methods are _not_ generated (yet?). We do generate various client stubs for languages, using the `msggen`[msggen] tool. More on the generated stubs and utilities below.
15
+
- We describe the JSON-RPC using [JSON Schema](https://json-schema.org/) in the [`doc/schemas`](https://github.com/ElementsProject/lightning/tree/master/doc/schemas) directory. Each method has a `lightning-*.json` for request and response. During tests the `pytest` target will verify responses, however the JSON-RPC methods are _not_ generated (yet?). We do generate various client stubs for languages, using the `msggen` tool. More on the generated stubs and utilities below.
16
16
17
17
## Man pages
18
18
@@ -26,21 +26,9 @@ The manpages are generated from the JSON schemas using the [`fromschema`](https:
26
26
27
27
`msggen` is used to generate JSON-RPC client stubs, and converters between in-memory formats and the JSON format. In addition, by chaining some of these we can expose a [grpc](https://grpc.io/) interface that matches the JSON-RPC interface. This conversion chain is implemented in the [grpc-plugin](https://github.com/ElementsProject/lightning/tree/master/plugins/grpc-plugin).
28
28
29
-
[block:image]
30
-
{
31
-
"images": [
32
-
{
33
-
"image": [
34
-
"https://files.readme.io/8777cc4-image.png",
35
-
null,
36
-
null
37
-
],
38
-
"align": "center",
39
-
"caption": "Artifacts generated from the JSON Schemas using `msggen`"
40
-
}
41
-
]
42
-
}
43
-
[/block]
29
+

30
+
31
+
*Artifacts generated from the JSON Schemas using `msggen`*
44
32
45
33
### `cln-rpc`
46
34
@@ -58,4 +46,4 @@ The `cln-grpc` crate is mostly used to provide the primitives to build the `grpc
58
46
- Next it generates the `convert.rs` file which is used to convert the structs for in-memory representation from `cln-rpc` into the corresponding protobuf structs.
59
47
- Finally `msggen` generates the `server.rs` file which can be bound to a grpc endpoint listening for incoming grpc requests, and it will convert the request and forward it to the JSON-RPC. Upon receiving the response it gets converted back into a grpc response and sent back.
60
48
61
-

49
+

Copy file name to clipboardExpand all lines: doc/contribute-to-core-lightning/contribute-to-core-lightning.md
+17-35Lines changed: 17 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,10 +14,10 @@ To read the code, you should start from [lightningd.c](https://github.com/Elemen
14
14
15
15
Here's a list of parts, with notes:
16
16
17
-
- ccan - useful routines from <http://ccodearchive.net>
17
+
- ccan - useful routines from http://ccodearchive.net
18
18
- Use make update-ccan to update it.
19
19
- Use make update-ccan CCAN_NEW="mod1 mod2..." to add modules
20
-
- Do not edit this! If you want a wrapper, add one to common/utils.h.
20
+
- Do not edit this! If you want a wrapper, add one to common/utils.h.
21
21
22
22
- bitcoin/ - bitcoin script, signature and transaction routines.
23
23
- Not a complete set, but enough for our purposes.
@@ -69,18 +69,15 @@ Here's a list of parts, with notes:
69
69
70
70
## Database
71
71
72
-
Core Lightning state is persisted in `lightning-dir`. It is a sqlite database stored in the `lightningd.sqlite3` file, typically under `~/.lightning/<network>/`.
73
-
You can run queries against this file like so:
72
+
Core Lightning state is persisted in `lightning-dir`. It is a sqlite database stored in the `lightningd.sqlite3` file, typically under `~/.lightning/<network>/`.
"SELECT HEX(prev_out_tx), prev_out_index, status FROM outputs"
78
78
```
79
79
80
-
81
-
82
80
Or you can launch into the sqlite3 repl and check things out from there:
83
-
84
81
```shell
85
82
$ sqlite3 ~/.lightning/bitcoin/lightningd.sqlite3
86
83
SQLite version 3.21.0 2017-10-24 18:55:49
@@ -93,16 +90,13 @@ sqlite> .schema outputs
93
90
...
94
91
```
95
92
96
-
97
-
98
93
Some data is stored as raw bytes, use `HEX(column)` to pretty print these.
99
94
100
95
Make sure that clightning is not running when you query the database, as some queries may lock the database and cause crashes.
101
96
102
97
#### Common variables
103
98
104
99
Table `vars` contains global variables used by lightning node.
105
-
106
100
```shell
107
101
$ sqlite3 ~/.lightning/bitcoin/lightningd.sqlite3
108
102
SQLite version 3.21.0 2017-10-24 18:55:49
@@ -115,55 +109,43 @@ bip32_max_index|4
115
109
...
116
110
```
117
111
118
-
119
-
120
112
Variables:
121
113
122
114
- `next_pay_index` next resolved invoice counter that will get assigned.
123
115
- `bip32_max_index` last wallet derivation counter.
124
116
125
-
Note: Each time`newaddr`command is called, `bip32_max_index` counter is increased to the last derivation index. Each address generated after `bip32_max_index` is not included as
126
-
lightning funds.
117
+
Note: Each time`newaddr`command is called, `bip32_max_index` counter is increased to the last derivation index. Each address generated after `bip32_max_index` is not included as lightning funds.
127
118
128
119
# gossip_store: Direct Access To Lightning Gossip
129
120
130
-
The `lightning_gossipd` daemon stores the gossip messages, along with some internal data, in a file called the "gossip_store". Various plugins and daemons access this (in a read-only manner), and the format is documented here.
121
+
The `lightning_gossipd` daemon stores the gossip messages, along with some internal data, in a file called the "gossip_store". Various plugins and daemons access this (in a read-only manner), and the format is documented here.
131
122
132
123
## The File Header
133
-
134
124
```
135
125
u8 version;
136
126
```
137
127
138
-
139
-
140
-
The gossmap header consists of one byte. The top 3 bits are the major version: if these are not all zero, you need to re-read this (updated) document to see what changed. The lower 5 bits are the minor version, which won't worry you: currently they will be 11.
128
+
The gossmap header consists of one byte. The top 3 bits are the major version: if these are not all zero, you need to re-read this (updated) document to see what changed. The lower 5 bits are the minor version, which won't worry you: currently they will be 11.
141
129
142
130
After the file header comes a number of records.
143
131
144
132
## The Record Header
145
-
146
133
```
147
134
be16 flags;
148
135
be16 len;
149
136
be32 crc;
150
137
be32 timestamp;
151
138
```
152
139
153
-
154
-
155
-
Each record consists of a header and a message. The header is big-endian, containing flags, the length (of the following body), the crc32c (of the following message, starting with the timestamp field in the header) and a timestamp extracted from certain messages (zero where not relevant, but ignore it in those cases).
140
+
Each record consists of a header and a message. The header is big-endian, containing flags, the length (of the following body), the crc32c (of the following message, starting with the timestamp field in the header) and a timestamp extracted from certain messages (zero where not relevant, but ignore it in those cases).
156
141
157
142
The flags currently defined are:
158
-
159
143
```
160
144
#define DELETED 0x8000
161
145
#define PUSH 0x4000
162
146
#define DYING 0x0800
163
147
```
164
148
165
-
166
-
167
149
Deleted fields should be ignored: on restart, they will be removed as the gossip_store is rewritten.
168
150
169
151
The push flag indicates gossip which is generated locally: this is important for gossip timestamp filtering, where peers request gossip and we always send our own gossip messages even if the timestamp wasn't within their request.
@@ -174,15 +156,15 @@ Other flags should be ignored.
174
156
175
157
## The Message
176
158
177
-
Each messages consists of a 16-bit big-endian "type" field (for efficiency, an implementation may read this along with the header), and optional data. Some messages are defined by the BOLT 7 gossip protocol, others are for internal use. Unknown message types should be skipped over.
159
+
Each messages consists of a 16-bit big-endian "type" field (for efficiency, an implementation may read this along with the header), and optional data. Some messages are defined by the BOLT 7 gossip protocol, others are for internal use. Unknown message types should be skipped over.
178
160
179
161
### BOLT 7 Messages
180
162
181
163
These are the messages which gossipd has validated, and ensured are in order.
182
164
183
-
- `channel_announcement` (256): a complete, validated channel announcement. This will always come before any `channel_update` which refers to it, or `node_announcement` which refers to a node.
184
-
- `channel_update` (258): a complete, validated channel update. Note that you can see multiple of these (old ones will be deleted as they are replaced though).
185
-
- `node_announcement` (257): a complete, validated node announcement. Note that you can also see multiple of these (old ones will be deleted as they are replaced).
165
+
- `channel_announcement` (256): a complete, validated channel announcement. This will always come before any `channel_update` which refers to it, or `node_announcement` which refers to a node.
166
+
- `channel_update` (258): a complete, validated channel update. Note that you can see multiple of these (old ones will be deleted as they are replaced though).
167
+
- `node_announcement` (257): a complete, validated node announcement. Note that you can also see multiple of these (old ones will be deleted as they are replaced).
186
168
187
169
### Internal Gossip Daemon Messages
188
170
@@ -209,26 +191,26 @@ This contains a private `channel_update` (i.e. for a channel described by `gossi
209
191
- `gossip_store_delete_chan` (4103)
210
192
- `scid`: u64
211
193
212
-
This is added when a channel is deleted. You won't often see this if you're reading the file once (as the channel record header will have been marked `deleted` first), but useful if you are polling the file for updates.
194
+
This is added when a channel is deleted. You won't often see this if you're reading the file once (as the channel record header will have been marked `deleted` first), but useful if you are polling the file for updates.
213
195
214
196
- `gossip_store_ended` (4105)
215
197
- `equivalent_offset`: u64
216
198
217
-
This is only ever added as the final entry in the gossip_store. It means the file has been deleted (usually because lightningd has been restarted), and you should re-open it. As an optimization, the `equivalent_offset` in the new file reflects the point at which the new gossip_store is equivalent to this one (with deleted records removed). However, if lightningd has been restarted multiple times it is possible that this offset is not valid, so it's really only useful if you're actively monitoring the file.
199
+
This is only ever added as the final entry in the gossip_store. It means the file has been deleted (usually because lightningd has been restarted), and you should re-open it. As an optimization, the `equivalent_offset` in the new file reflects the point at which the new gossip_store is equivalent to this one (with deleted records removed). However, if lightningd has been restarted multiple times it is possible that this offset is not valid, so it's really only useful if you're actively monitoring the file.
218
200
219
201
- `gossip_store_chan_dying` (4106)
220
202
- `scid`: u64
221
203
- `blockheight`: u32
222
204
223
-
This is placed in the gossip_store file when a funding transaction is spent. `blockheight` is set to 12 blocks beyond the block containing the spend: at this point, gossipd will delete the channel.
205
+
This is placed in the gossip_store file when a funding transaction is spent. `blockheight` is set to 12 blocks beyond the block containing the spend: at this point, gossipd will delete the channel.
224
206
225
207
## Using the Gossip Store File
226
208
227
-
- Always check the major version number! We will increment it if the format changes in a way that breaks readers.
209
+
- Always check the major version number! We will increment it if the format changes in a way that breaks readers.
228
210
- Ignore unknown flags in the header.
229
211
- Ignore message types you don't know.
230
212
- You don't need to check the messages, as they have been validated.
231
-
- It is possible to see a partially-written record at the end. Ignore it.
213
+
- It is possible to see a partially-written record at the end. Ignore it.
232
214
233
215
If you are keeping the file open to watch for changes:
0 commit comments