From 5797dc6496d1f7ba99be78ccfde8dbda550e1cd0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 7 Oct 2016 17:40:04 +1030 Subject: [PATCH] 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 --- daemon/packets.c | 6 ++++++ daemon/peer.c | 21 +++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/daemon/packets.c b/daemon/packets.c index cee0f518a..046595e22 100644 --- a/daemon/packets.c +++ b/daemon/packets.c @@ -241,6 +241,12 @@ Pkt *pkt_init(struct peer *peer, u64 ack) Init *i = tal(peer, Init); init__init(i); i->ack = ack; + /* BOLT #2: + * + * A node SHOULD set the `features` field of the `init` + * message to a bitset representing features it supports. + */ + /* No features yet! */ return make_pkt(peer, PKT__PKT_INIT, i); } diff --git a/daemon/peer.c b/daemon/peer.c index d2530c8a0..fbc6a7af9 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -2108,6 +2108,11 @@ static struct io_plan *init_pkt_in(struct io_conn *conn, struct peer *peer) if (peer->inpkt->init->has_features) { size_t i; + /* BOLT #2: + * + * The receiving node SHOULD ignore any odd feature bits it + * does not support, and MUST fail the connection if any + * unsupported even `features` bit is set. */ for (i = 0; i < peer->inpkt->init->features.len*CHAR_BIT; i++) { size_t byte = i / CHAR_BIT, bit = i % CHAR_BIT; if (peer->inpkt->init->features.data[byte] & (1<