MCPcopy Create free account
hub / github.com/ElementsProject/lightning / handle_channel_announcement

Function handle_channel_announcement

gossipd/routing.c:975–1154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

973}
974
975u8 *handle_channel_announcement(struct routing_state *rstate,
976 const u8 *announce TAKES,
977 u32 current_blockheight,
978 const struct short_channel_id **scid,
979 struct peer *peer)
980{
981 struct pending_cannouncement *pending;
982 struct bitcoin_blkid chain_hash;
983 u8 *features, *warn;
984 secp256k1_ecdsa_signature node_signature_1, node_signature_2;
985 secp256k1_ecdsa_signature bitcoin_signature_1, bitcoin_signature_2;
986 struct chan *chan;
987
988 pending = tal(rstate, struct pending_cannouncement);
989 set_softref(pending, &pending->peer_softref, peer);
990 pending->updates[0] = NULL;
991 pending->updates[1] = NULL;
992 pending->update_peer_softref[0] = pending->update_peer_softref[1] = NULL;
993 pending->announce = tal_dup_talarr(pending, u8, announce);
994 pending->update_timestamps[0] = pending->update_timestamps[1] = 0;
995
996 if (!fromwire_channel_announcement(pending, pending->announce,
997 &node_signature_1,
998 &node_signature_2,
999 &bitcoin_signature_1,
1000 &bitcoin_signature_2,
1001 &features,
1002 &chain_hash,
1003 &pending->short_channel_id,
1004 &pending->node_id_1,
1005 &pending->node_id_2,
1006 &pending->bitcoin_key_1,
1007 &pending->bitcoin_key_2)) {
1008 warn = towire_warningfmt(rstate, NULL,
1009 "Malformed channel_announcement %s",
1010 tal_hex(pending, pending->announce));
1011 goto malformed;
1012 }
1013
1014 /* We don't use features */
1015 tal_free(features);
1016
1017 /* If we know the blockheight, and it's in the future, reject
1018 * out-of-hand. Remember, it should be 6 deep before they tell us
1019 * anyway. */
1020 if (current_blockheight != 0
1021 && short_channel_id_blocknum(&pending->short_channel_id) > current_blockheight) {
1022 status_peer_debug(peer ? &peer->id : NULL,
1023 "Ignoring future channel_announcment for %s"
1024 " (current block %u)",
1025 type_to_string(tmpctx, struct short_channel_id,
1026 &pending->short_channel_id),
1027 current_blockheight);
1028 goto ignored;
1029 }
1030
1031 /* If a prior txout lookup failed there is little point it trying
1032 * again. Just drop the announcement and walk away whistling. */

Callers 1

Calls 12

tal_hexFunction · 0.85
tal_freeFunction · 0.85
in_txout_failuresFunction · 0.85
get_channelFunction · 0.85
is_chan_publicFunction · 0.85
get_unupdated_channelFunction · 0.85
catch_node_announcementFunction · 0.85
towire_warningfmtFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected