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

Function process_channel_update

gossipd/gossmap_manage.c:878–993  ·  view source on GitHub ↗

This is called both from when we receive the channel update, and if * we had to defer. */

Source from the content-addressed store, hash-verified

876/* This is called both from when we receive the channel update, and if
877 * we had to defer. */
878static const char *process_channel_update(const tal_t *ctx,
879 struct gossmap_manage *gm,
880 struct short_channel_id scid,
881 const secp256k1_ecdsa_signature *signature,
882 u8 message_flags,
883 u8 channel_flags,
884 u16 cltv_expiry_delta,
885 struct amount_msat htlc_minimum_msat,
886 struct amount_msat htlc_maximum_msat,
887 u32 fee_base_msat,
888 u32 fee_proportional_millionths,
889 u32 timestamp,
890 const u8 *update,
891 const struct node_id *source_peer)
892{
893 struct gossmap_chan *chan;
894 struct node_id node_id, remote_id;
895 const char *err;
896 int dir = (channel_flags & ROUTING_FLAGS_DIRECTION);
897 struct gossmap *gossmap = gossmap_manage_get_gossmap(gm);
898 u64 offset;
899
900 chan = gossmap_find_chan(gossmap, &scid);
901 if (!chan) {
902 /* Did we explicitly reject announce? Ignore completely. */
903 if (in_txout_failures(gm->txf, scid)) {
904 status_debug("Previously-rejected announce for %s",
905 fmt_short_channel_id(tmpctx, scid));
906 return NULL;
907 }
908
909 /* Seeker may want to ask about this. */
910 query_unknown_channel(gm->daemon, source_peer, scid);
911
912 /* Don't send them warning, it can happen. */
913 bad_gossip(source_peer,
914 tal_fmt(tmpctx, "Unknown channel %s",
915 fmt_short_channel_id(tmpctx, scid)));
916 return NULL;
917 }
918
919 /* Now we know node, we can check signature. */
920 gossmap_node_get_id(gossmap,
921 gossmap_nth_node(gossmap, chan, dir),
922 &node_id);
923
924 err = sigcheck_channel_update(ctx, &node_id, signature, update);
925 if (err)
926 return err;
927
928 /* Don't allow private updates on public channels! */
929 if (message_flags & ROUTING_OPT_DONT_FORWARD) {
930 return tal_fmt(ctx, "Do not set DONT_FORWARD on public channel_updates (%s)",
931 fmt_short_channel_id(tmpctx, scid));
932 }
933
934 /* Do we have same or earlier update? */
935 if (gossmap_chan_set(chan, dir)) {

Callers 2

process_pending_cupdateFunction · 0.85

Calls 15

gossmap_find_chanFunction · 0.85
in_txout_failuresFunction · 0.85
fmt_short_channel_idFunction · 0.85
query_unknown_channelFunction · 0.85
bad_gossipFunction · 0.85
gossmap_node_get_idFunction · 0.85
gossmap_nth_nodeFunction · 0.85
sigcheck_channel_updateFunction · 0.85
gossmap_chan_setFunction · 0.85
gossip_store_addFunction · 0.85

Tested by

no test coverage detected