mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
gossipd: Check features in node_announcement and channel_announcement.
Fixes: #548
This commit is contained in:
committed by
Christian Decker
parent
83e76e3ac3
commit
a2877232af
@@ -40,6 +40,7 @@ GOSSIPD_COMMON_OBJS := \
|
|||||||
common/cryptomsg.o \
|
common/cryptomsg.o \
|
||||||
common/daemon_conn.o \
|
common/daemon_conn.o \
|
||||||
common/dev_disconnect.o \
|
common/dev_disconnect.o \
|
||||||
|
common/features.o \
|
||||||
common/io_debug.o \
|
common/io_debug.o \
|
||||||
common/msg_queue.o \
|
common/msg_queue.o \
|
||||||
common/ping.o \
|
common/ping.o \
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <ccan/endian/endian.h>
|
#include <ccan/endian/endian.h>
|
||||||
#include <ccan/structeq/structeq.h>
|
#include <ccan/structeq/structeq.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/features.h>
|
||||||
#include <common/pseudorand.h>
|
#include <common/pseudorand.h>
|
||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
@@ -554,6 +555,20 @@ const struct short_channel_id *handle_channel_announcement(
|
|||||||
tag = type_to_string(pending, struct short_channel_id,
|
tag = type_to_string(pending, struct short_channel_id,
|
||||||
&pending->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:
|
/* BOLT #7:
|
||||||
*
|
*
|
||||||
* The receiving node MUST ignore the message if the specified
|
* The receiving node MUST ignore the message if the specified
|
||||||
@@ -568,8 +583,6 @@ const struct short_channel_id *handle_channel_announcement(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Check features!
|
|
||||||
|
|
||||||
if (!check_channel_announcement(&pending->node_id_1, &pending->node_id_2,
|
if (!check_channel_announcement(&pending->node_id_1, &pending->node_id_2,
|
||||||
&pending->bitcoin_key_1,
|
&pending->bitcoin_key_1,
|
||||||
&pending->bitcoin_key_2,
|
&pending->bitcoin_key_2,
|
||||||
@@ -873,7 +886,19 @@ void handle_node_announcement(
|
|||||||
return;
|
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",
|
status_trace("Received node_announcement for node %s",
|
||||||
type_to_string(trc, struct pubkey, &node_id));
|
type_to_string(trc, struct pubkey, &node_id));
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ GOSSIPD_TEST_OBJS := $(GOSSIPD_TEST_SRC:.c=.o)
|
|||||||
GOSSIPD_TEST_PROGRAMS := $(GOSSIPD_TEST_OBJS:.o=)
|
GOSSIPD_TEST_PROGRAMS := $(GOSSIPD_TEST_OBJS:.o=)
|
||||||
|
|
||||||
GOSSIPD_TEST_COMMON_OBJS := \
|
GOSSIPD_TEST_COMMON_OBJS := \
|
||||||
|
common/features.o \
|
||||||
common/pseudorand.o \
|
common/pseudorand.o \
|
||||||
common/type_to_string.o \
|
common/type_to_string.o \
|
||||||
common/utils.o
|
common/utils.o
|
||||||
|
|||||||
Reference in New Issue
Block a user