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

Function add_connection

common/test/run-route.c:89–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89static void add_connection(int store_fd,
90 const struct node_id *from,
91 const struct node_id *to,
92 u32 base_fee, s32 proportional_fee,
93 u32 delay)
94{
95 struct short_channel_id scid;
96 secp256k1_ecdsa_signature dummy_sig;
97 struct secret not_a_secret;
98 struct pubkey dummy_key;
99 u8 *msg;
100 const struct node_id *ids[2];
101
102 /* So valgrind doesn't complain */
103 memset(&dummy_sig, 0, sizeof(dummy_sig));
104 memset(&not_a_secret, 1, sizeof(not_a_secret));
105 pubkey_from_secret(&not_a_secret, &dummy_key);
106
107 /* Make a unique scid. */
108 memcpy(&scid, from, sizeof(scid) / 2);
109 memcpy((char *)&scid + sizeof(scid) / 2, to, sizeof(scid) / 2);
110
111 if (node_id_cmp(from, to) > 0) {
112 ids[0] = to;
113 ids[1] = from;
114 } else {
115 ids[0] = from;
116 ids[1] = to;
117 }
118 msg = towire_channel_announcement(tmpctx, &dummy_sig, &dummy_sig,
119 &dummy_sig, &dummy_sig,
120 /* features */ NULL,
121 &chainparams->genesis_blockhash,
122 &scid,
123 ids[0], ids[1],
124 &dummy_key, &dummy_key);
125 write_to_store(store_fd, msg);
126
127 update_connection(store_fd, from, to, base_fee, proportional_fee,
128 delay, false);
129}
130
131static bool channel_is_between(const struct gossmap *gossmap,
132 const struct route_hop *route,

Callers 1

mainFunction · 0.70

Calls 4

pubkey_from_secretFunction · 0.85
write_to_storeFunction · 0.70
update_connectionFunction · 0.70
node_id_cmpFunction · 0.50

Tested by

no test coverage detected