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

Function write_announce

devtools/gossmap-compress.c:326–366  ·  view source on GitHub ↗

BOLT #7: * 1. type: 256 (`channel_announcement`) * 2. data: * * [`signature`:`node_signature_1`] * * [`signature`:`node_signature_2`] * * [`signature`:`bitcoin_signature_1`] * * [`signature`:`bitcoin_signature_2`] * * [`u16`:`len`] * * [`len*byte`:`features`] * * [`chain_hash`:`chain_hash`] * * [`short_channel_id`:`short_channel_id`] * * [`point`:`nod

Source from the content-addressed store, hash-verified

324 * * [`point`:`bitcoin_key_2`]
325 */
326static void write_announce(int outfd,
327 size_t node1,
328 size_t node2,
329 u64 capacity,
330 size_t i,
331 const struct pubkey **node_ids)
332{
333 struct {
334 secp256k1_ecdsa_signature sig;
335 struct bitcoin_blkid chain_hash;
336 } vals;
337 u8 *msg;
338 struct short_channel_id scid;
339 struct pubkey id1, id2;
340 struct node_id nodeid1, nodeid2;
341
342 memset(&vals, 0, sizeof(vals));
343 pubkey_for_node(node1, &id1, node_ids);
344 pubkey_for_node(node2, &id2, node_ids);
345
346 /* Nodes in pubkey order */
347 if (pubkey_cmp(&id1, &id2) < 0) {
348 node_id_from_pubkey(&nodeid1, &id1);
349 node_id_from_pubkey(&nodeid2, &id2);
350 } else {
351 node_id_from_pubkey(&nodeid1, &id2);
352 node_id_from_pubkey(&nodeid2, &id1);
353 }
354 /* Use i to avoid clashing scids even if two nodes have > 1 channel */
355 if (!mk_short_channel_id(&scid, i + node1, node2, i & 0xFFFF))
356 abort();
357
358 msg = towire_channel_announcement(NULL, &vals.sig, &vals.sig, &vals.sig, &vals.sig,
359 NULL, &vals.chain_hash, scid,
360 &nodeid1, &nodeid2,
361 &id1, &id1);
362 write_msg_to_gstore(outfd, take(msg));
363
364 msg = towire_gossip_store_channel_amount(NULL, amount_sat(capacity));
365 write_msg_to_gstore(outfd, take(msg));
366}
367
368/* BOLT #7:
369 * 1. type: 258 (`channel_update`)

Callers 1

mainFunction · 0.85

Calls 7

pubkey_for_nodeFunction · 0.85
pubkey_cmpFunction · 0.85
node_id_from_pubkeyFunction · 0.85
mk_short_channel_idFunction · 0.85
abortFunction · 0.85
write_msg_to_gstoreFunction · 0.85
amount_satClass · 0.70

Tested by

no test coverage detected