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

Function add_connection

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

Source from the content-addressed store, hash-verified

94}
95
96static void add_connection(int store_fd,
97 const struct node_id *from,
98 const struct node_id *to,
99 u32 base_fee, s32 proportional_fee,
100 u32 delay)
101{
102 struct short_channel_id scid;
103 secp256k1_ecdsa_signature dummy_sig;
104 struct secret not_a_secret;
105 struct pubkey dummy_key;
106 u8 *msg;
107 const struct node_id *ids[2];
108
109 /* So valgrind doesn't complain */
110 memset(&dummy_sig, 0, sizeof(dummy_sig));
111 memset(&not_a_secret, 1, sizeof(not_a_secret));
112 pubkey_from_secret(&not_a_secret, &dummy_key);
113
114 /* Make a unique scid. */
115 memcpy(&scid, from, sizeof(scid) / 2);
116 memcpy((char *)&scid + sizeof(scid) / 2, to, sizeof(scid) / 2);
117
118 if (node_id_cmp(from, to) > 0) {
119 ids[0] = to;
120 ids[1] = from;
121 } else {
122 ids[0] = from;
123 ids[1] = to;
124 }
125 msg = towire_channel_announcement(tmpctx, &dummy_sig, &dummy_sig,
126 &dummy_sig, &dummy_sig,
127 /* features */ NULL,
128 &chainparams->genesis_blockhash,
129 scid,
130 ids[0], ids[1],
131 &dummy_key, &dummy_key);
132 write_to_store(store_fd, msg);
133
134 /* Also needs a hint as to the funding size. */
135 struct amount_sat capacity = AMOUNT_SAT(100000000);
136 msg = towire_gossip_store_channel_amount(tmpctx, capacity);
137 write_to_store(store_fd, msg);
138 tal_free(msg);
139 update_connection(store_fd, from, to, base_fee, proportional_fee, delay,
140 false);
141}
142
143static bool channel_is_between(const struct gossmap *gossmap,
144 const struct route_hop *route,

Callers 1

mainFunction · 0.70

Calls 5

pubkey_from_secretFunction · 0.85
node_id_cmpFunction · 0.85
tal_freeFunction · 0.85
write_to_storeFunction · 0.70
update_connectionFunction · 0.70

Tested by

no test coverage detected