mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user