Skip to content

Commit 7b01692

Browse files
authored
BOLT 1: add networks to init message. (#682)
Add networks to init message via TLV extension. This prevents accidentally connecting a testnet node to mainnet or the other way around.
1 parent 3847935 commit 7b01692

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

01-messaging.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,17 @@ The `features` field MUST be padded to bytes with 0s.
244244
* [`gflen*byte`:`globalfeatures`]
245245
* [`u16`:`flen`]
246246
* [`flen*byte`:`features`]
247+
* [`init_tlvs`:`tlvs`]
248+
249+
1. tlvs: `init_tlvs`
250+
2. types:
251+
1. type: 1 (`networks`)
252+
2. data:
253+
* [`...*chain_hash`:`chains`]
247254

248255

256+
The optional `networks` indicates the chains the node is interested in.
257+
249258
#### Requirements
250259

251260
The sending node:
@@ -254,6 +263,7 @@ The sending node:
254263
- MUST set any undefined feature bits to 0.
255264
- SHOULD NOT set features greater than 13 in `globalfeatures`.
256265
- SHOULD use the minimum length required to represent the `features` field.
266+
- SHOULD set `networks` to all chains it will gossip or open channels for.
257267

258268
The receiving node:
259269
- MUST wait to receive `init` before sending any other messages.
@@ -263,6 +273,8 @@ The receiving node:
263273
- MUST ignore the bit.
264274
- upon receiving unknown _even_ feature bits that are non-zero:
265275
- MUST fail the connection.
276+
- upon receiving `networks` containing no common chains
277+
- MAY fail the connection.
266278
- if the feature vector does not set all known, transitive dependencies:
267279
- MUST fail the connection.
268280

@@ -276,6 +288,11 @@ This semantic allows both future incompatible changes and future backward compat
276288
Nodes wait for receipt of the other's features to simplify error
277289
diagnosis when features are incompatible.
278290

291+
Since all networks share the same port, but most implementations only
292+
support a single network, the `networks` fields avoids nodes
293+
erroneously believing they will receive updates about their preferred
294+
network, or that they can open channels.
295+
279296
### The `error` Message
280297

281298
For simplicity of diagnosis, it's often useful to tell a peer that something is incorrect.

07-routing-gossip.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,8 @@ A node:
917917
the arrival times of the messages.
918918
- Note: this results in staggered announcements that are unique (not
919919
duplicated).
920+
- SHOULD NOT forward gossip messages to peers who sent `networks` in `init`
921+
and did not specify the `chain_hash` of this gossip message.
920922
- MAY re-announce its channels regularly.
921923
- Note: this is discouraged, in order to keep the resource requirements low.
922924
- upon connection establishment:

0 commit comments

Comments
 (0)