From 45ad2498f3d59046dfbe195f86fdf9548bc5c4e3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 2 Aug 2018 16:19:56 +0930 Subject: [PATCH] connectd: check for supported features ourselves. Checking in the master doesn't help anything, and it's weird. Signed-off-by: Rusty Russell 1diff --git a/connectd/connect.c b/connectd/connect.c index 138b73fc..b01d1546 100644 --- connectd/connect.c | 20 ++++++++++++++++++++ lightningd/peer_control.c | 21 --------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/connectd/connect.c b/connectd/connect.c index e0a336462..ea7d50d12 100644 --- a/connectd/connect.c +++ b/connectd/connect.c @@ -562,6 +562,26 @@ static struct io_plan *peer_init_received(struct io_conn *conn, return io_close(conn); } + if (!features_supported(peer->gfeatures, peer->lfeatures)) { + const u8 *global_features = get_offered_global_features(msg); + const u8 *local_features = get_offered_local_features(msg); + msg = towire_errorfmt(NULL, NULL, "Unsupported features %s/%s:" + " we only offer globalfeatures %s" + " and localfeatures %s", + tal_hex(msg, peer->gfeatures), + tal_hex(msg, peer->lfeatures), + tal_hexstr(msg, + global_features, + tal_count(global_features)), + tal_hexstr(msg, + local_features, + tal_count(local_features))); + queue_peer_msg(peer, take(msg)); + + /* Don't read any more */ + return io_wait(conn, peer, io_never, peer); + } + return peer_connected(conn, peer); } diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 96726fa75..05d462bb2 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -445,8 +445,6 @@ void peer_connected(struct lightningd *ld, const u8 *msg, struct crypto_state cs; u8 *gfeatures, *lfeatures; u8 *error; - u8 *global_features; - u8 *local_features; struct channel *channel; struct wireaddr_internal addr; struct uncommitted_channel *uc; @@ -457,25 +455,6 @@ void peer_connected(struct lightningd *ld, const u8 *msg, fatal("Connectd gave bad CONNECT_PEER_CONNECTED message %s", tal_hex(msg, msg)); - if (!features_supported(gfeatures, lfeatures)) { - log_unusual(ld->log, "peer %s offers unsupported features %s/%s", - type_to_string(msg, struct pubkey, &id), - tal_hex(msg, gfeatures), - tal_hex(msg, lfeatures)); - global_features = get_offered_global_features(msg); - local_features = get_offered_local_features(msg); - error = towire_errorfmt(msg, NULL, - "We only offer globalfeatures %s" - " and localfeatures %s", - tal_hexstr(msg, - global_features, - tal_count(global_features)), - tal_hexstr(msg, - local_features, - tal_count(local_features))); - goto send_error; - } - /* Were we trying to open a channel, and we've raced? */ if (handle_opening_channel(ld, &id, &addr, &cs, gfeatures, lfeatures, peer_fd, gossip_fd))