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

Function add_connection

common/test/run-route-specific.c:105–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105static void add_connection(int store_fd,
106 const struct node_id *from,
107 const struct node_id *to,
108 const char *shortid,
109 struct amount_msat min,
110 struct amount_msat max,
111 u32 base_fee, s32 proportional_fee,
112 u32 delay)
113{
114 struct short_channel_id scid;
115 secp256k1_ecdsa_signature dummy_sig;
116 struct secret not_a_secret;
117 struct pubkey dummy_key;
118 u8 *msg;
119 const struct node_id *ids[2];
120
121 /* So valgrind doesn't complain */
122 memset(&dummy_sig, 0, sizeof(dummy_sig));
123 memset(&not_a_secret, 1, sizeof(not_a_secret));
124 pubkey_from_secret(&not_a_secret, &dummy_key);
125
126 if (!short_channel_id_from_str(shortid, strlen(shortid), &scid))
127 abort();
128
129 if (node_id_cmp(from, to) > 0) {
130 ids[0] = to;
131 ids[1] = from;
132 } else {
133 ids[0] = from;
134 ids[1] = to;
135 }
136 msg = towire_channel_announcement(tmpctx, &dummy_sig, &dummy_sig,
137 &dummy_sig, &dummy_sig,
138 /* features */ NULL,
139 &chainparams->genesis_blockhash,
140 scid,
141 ids[0], ids[1],
142 &dummy_key, &dummy_key);
143 write_to_store(store_fd, msg);
144 tal_free(msg);
145
146 /* Also needs a hint as to the funding size. */
147 struct amount_sat capacity = AMOUNT_SAT(100000000);
148 msg = towire_gossip_store_channel_amount(tmpctx, capacity);
149 write_to_store(store_fd, msg);
150 tal_free(msg);
151
152 update_connection(store_fd, from, to, shortid, min, max,
153 base_fee, proportional_fee,
154 delay, false);
155}
156
157static bool channel_is_between(const struct gossmap *gossmap,
158 const struct route_hop *route,

Callers 1

mainFunction · 0.70

Calls 7

pubkey_from_secretFunction · 0.85
abortFunction · 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