From bcb287f89b93de0daa0b85ab092344e504d9019c Mon Sep 17 00:00:00 2001 From: trueptolemy <823220586@qq.com> Date: Mon, 15 Apr 2019 09:20:09 +0800 Subject: [PATCH] hsmd: add the check for channel_announcement --- hsmd/hsmd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hsmd/hsmd.c b/hsmd/hsmd.c index 924fc476c..a34a91238 100644 --- a/hsmd/hsmd.c +++ b/hsmd/hsmd.c @@ -630,6 +630,9 @@ static struct io_plan *handle_cannouncement_sig(struct io_conn *conn, * yourself should go ahead an implement. Sometimes they're deceptive * quagmires which will cause you nothing but grief. You decide! */ + /*~ Christian uses TODO(cdecker) or FIXME(cdecker), but I'm sure he won't + * mind if you fix this for him! */ + /* FIXME: We should cache these. */ get_channel_seed(&c->id, c->dbid, &channel_seed); derive_funding_key(&channel_seed, &funding_pubkey, &funding_privkey); @@ -645,10 +648,10 @@ static struct io_plan *handle_cannouncement_sig(struct io_conn *conn, "bad cannounce length %zu", tal_count(ca)); - /*~ Christian uses TODO(cdecker), but I'm sure he won't mind if you fix - * this for him! */ - /* TODO(cdecker) Check that this is actually a valid - * channel_announcement */ + if (fromwire_peektype(ca) != WIRE_CHANNEL_ANNOUNCEMENT) + return bad_req_fmt(conn, c, msg_in, + "Invalid channel announcement"); + node_key(&node_pkey, NULL); sha256_double(&hash, ca + offset, tal_count(ca) - offset);