diff --git a/gossipd/Makefile b/gossipd/Makefile index 310a60125..5740cc93e 100644 --- a/gossipd/Makefile +++ b/gossipd/Makefile @@ -40,6 +40,7 @@ GOSSIPD_COMMON_OBJS := \ common/cryptomsg.o \ common/daemon_conn.o \ common/dev_disconnect.o \ + common/features.o \ common/io_debug.o \ common/msg_queue.o \ common/ping.o \ diff --git a/gossipd/routing.c b/gossipd/routing.c index 99e5217fe..ea4949ea8 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -554,6 +555,20 @@ const struct short_channel_id *handle_channel_announcement( tag = type_to_string(pending, struct short_channel_id, &pending->short_channel_id); + /* BOLT #7: + * + * If there is an unknown even bit in the `features` field the + * receiving node MUST NOT parse the remainder of the message + * and MUST NOT add the channel to its local network view, and + * SHOULD NOT forward the announcement. + */ + if (unsupported_features(features, NULL)) { + status_trace("Ignoring channel announcement, unsupported features %s.", + tal_hex(pending, features)); + tal_free(pending); + return NULL; + } + /* BOLT #7: * * The receiving node MUST ignore the message if the specified @@ -568,8 +583,6 @@ const struct short_channel_id *handle_channel_announcement( return NULL; } - // FIXME: Check features! - if (!check_channel_announcement(&pending->node_id_1, &pending->node_id_2, &pending->bitcoin_key_1, &pending->bitcoin_key_2, @@ -873,7 +886,19 @@ void handle_node_announcement( return; } - // FIXME: Check features! + /* BOLT #7: + * + * If the `features` field contains unknown even bits the + * receiving node MUST NOT parse the remainder of the message + * and MAY discard the message altogether. + */ + if (unsupported_features(features, NULL)) { + status_trace("Ignoring node announcement, unsupported features %s.", + tal_hex(tmpctx, features)); + tal_free(tmpctx); + return; + } + status_trace("Received node_announcement for node %s", type_to_string(trc, struct pubkey, &node_id)); diff --git a/gossipd/test/Makefile b/gossipd/test/Makefile index b55dc69f0..04b14dad0 100644 --- a/gossipd/test/Makefile +++ b/gossipd/test/Makefile @@ -7,6 +7,7 @@ GOSSIPD_TEST_OBJS := $(GOSSIPD_TEST_SRC:.c=.o) GOSSIPD_TEST_PROGRAMS := $(GOSSIPD_TEST_OBJS:.o=) GOSSIPD_TEST_COMMON_OBJS := \ + common/features.o \ common/pseudorand.o \ common/type_to_string.o \ common/utils.o