Browse Source

channeld: check short_channel_ids match before announcing channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
cc60735aee
  1. 28
      channeld/channel.c

28
channeld/channel.c

@ -468,11 +468,30 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
send_announcement_signatures(peer); send_announcement_signatures(peer);
} }
/* Once we have both, we'd better make sure we agree what they are! */
static void check_short_ids_match(struct peer *peer)
{
assert(peer->have_sigs[LOCAL]);
assert(peer->have_sigs[REMOTE]);
if (!short_channel_id_eq(&peer->short_channel_ids[LOCAL],
&peer->short_channel_ids[REMOTE]))
peer_failed(PEER_FD, &peer->cs, &peer->channel_id,
"We disagree on short_channel_ids:"
" I have %s, you say %s",
type_to_string(peer, struct short_channel_id,
&peer->short_channel_ids[LOCAL]),
type_to_string(peer, struct short_channel_id,
&peer->short_channel_ids[REMOTE]));
}
static void announce_channel(struct peer *peer) static void announce_channel(struct peer *peer)
{ {
tal_t *tmpctx = tal_tmpctx(peer); tal_t *tmpctx = tal_tmpctx(peer);
u8 *cannounce, *cupdate; u8 *cannounce, *cupdate;
check_short_ids_match(peer);
cannounce = create_channel_announcement(tmpctx, peer); cannounce = create_channel_announcement(tmpctx, peer);
cupdate = create_channel_update(tmpctx, peer, false); cupdate = create_channel_update(tmpctx, peer, false);
@ -496,13 +515,12 @@ static void handle_peer_announcement_signatures(struct peer *peer, const u8 *msg
tal_hex(msg, msg)); tal_hex(msg, msg));
/* Make sure we agree on the channel ids */ /* Make sure we agree on the channel ids */
/* FIXME: Check short_channel_id */
if (!structeq(&chanid, &peer->channel_id)) { if (!structeq(&chanid, &peer->channel_id)) {
peer_failed(PEER_FD, &peer->cs, &peer->channel_id, peer_failed(PEER_FD, &peer->cs, &peer->channel_id,
"Wrong channel_id or short_channel_id in %s or %s", "Wrong channel_id: expected %s, got %s",
tal_hexstr(trc, &chanid, sizeof(struct channel_id)), type_to_string(trc, struct channel_id,
tal_hexstr(trc, &peer->short_channel_ids[REMOTE], &peer->channel_id),
sizeof(struct short_channel_id))); type_to_string(trc, struct channel_id, &chanid));
} }
peer->have_sigs[REMOTE] = true; peer->have_sigs[REMOTE] = true;

Loading…
Cancel
Save