connectd: do feature bits check after init exchange.

This will help with the next patch, where we wean off using a global
for features: connectd.c has access to the feature bits.

Since connectd might now want to send a message, it needs the crypto_state
non-const, which makes this less trivial than it would otherwise be.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-04-02 14:33:47 +10:30
parent 7c0af81c21
commit 15f54878e4
8 changed files with 36 additions and 36 deletions

View File

@@ -44,7 +44,6 @@ static struct io_plan *peer_init_received(struct io_conn *conn,
{
u8 *msg = cryptomsg_decrypt_body(tmpctx, &peer->cs, peer->msg);
u8 *globalfeatures, *features;
int unsup;
struct tlv_init_tlvs *tlvs = tlv_init_tlvs_new(msg);
if (!msg)
@@ -89,23 +88,6 @@ static struct io_plan *peer_init_received(struct io_conn *conn,
* window where it was: combine the two. */
features = featurebits_or(tmpctx, take(features), globalfeatures);
/* BOLT #1:
*
* The receiving node:
* ...
* - upon receiving unknown _odd_ feature bits that are non-zero:
* - MUST ignore the bit.
* - upon receiving unknown _even_ feature bits that are non-zero:
* - MUST fail the connection.
*/
unsup = features_unsupported(features);
if (unsup != -1) {
msg = towire_errorfmt(NULL, NULL, "Unsupported feature %u",
unsup);
msg = cryptomsg_encrypt_msg(NULL, &peer->cs, take(msg));
return io_write(conn, msg, tal_count(msg), io_close_cb, NULL);
}
/* Usually return io_close_taken_fd, but may wait for old peer to
* be disconnected if it's a reconnect. */
return peer_connected(conn, peer->daemon, &peer->id,