Skip to content

Commit 5797dc6

Browse files
committed
init: add comments as per updated BOLT #2.
To match 8ad8041990dc "wire-protocol: rename reconnect_pkt to init_pkt, add feature bits." Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 5e078a8 commit 5797dc6

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

daemon/packets.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ Pkt *pkt_init(struct peer *peer, u64 ack)
241241
Init *i = tal(peer, Init);
242242
init__init(i);
243243
i->ack = ack;
244+
/* BOLT #2:
245+
*
246+
* A node SHOULD set the `features` field of the `init`
247+
* message to a bitset representing features it supports.
248+
*/
249+
/* No features yet! */
244250
return make_pkt(peer, PKT__PKT_INIT, i);
245251
}
246252

daemon/peer.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,11 @@ static struct io_plan *init_pkt_in(struct io_conn *conn, struct peer *peer)
21082108
if (peer->inpkt->init->has_features) {
21092109
size_t i;
21102110

2111+
/* BOLT #2:
2112+
*
2113+
* The receiving node SHOULD ignore any odd feature bits it
2114+
* does not support, and MUST fail the connection if any
2115+
* unsupported even `features` bit is set. */
21112116
for (i = 0; i < peer->inpkt->init->features.len*CHAR_BIT; i++) {
21122117
size_t byte = i / CHAR_BIT, bit = i % CHAR_BIT;
21132118
if (peer->inpkt->init->features.data[byte] & (1<<bit)) {
@@ -2176,16 +2181,12 @@ static struct io_plan *peer_send_init(struct io_conn *conn, struct peer *peer)
21762181

21772182
/* BOLT #2:
21782183
*
2179-
* A node reconnecting after receiving or sending an `open_channel`
2180-
* message SHOULD send a `reconnect` message on the new connection
2181-
* immediately after it has validated the `authenticate` message. */
2182-
2183-
/* BOLT #2:
2184-
*
2185-
* A node MUST set the `ack` field in the `reconnect` message to the
2186-
* the sum of previously-processed messages of types
2187-
* `open_commit_sig`, `update_commit`, `update_revocation`,
2188-
* `close_shutdown` and `close_signature`. */
2184+
* A node MUST send an `init` message immediately immediately after
2185+
* it has validated the `authenticate` message. A node MUST set
2186+
* the `ack` field in the `init` message to the the sum of
2187+
* previously-processed messages of types `open_commit_sig`,
2188+
* `update_commit`, `update_revocation`, `close_shutdown` and
2189+
* `close_signature`. */
21892190
return peer_write_packet(conn, peer,
21902191
pkt_init(peer, sigs + revokes
21912192
+ shutdown + closing),

0 commit comments

Comments
 (0)