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

Function main

plugins/renepay/test/run-mcf.c:275–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273static void remove_file(char *fname) { assert(!remove(fname)); }
274
275int main(int argc, char *argv[])
276{
277 int fd;
278 char *gossfile;
279 struct gossmap *gossmap;
280 struct node_id l1, l2, l3;
281 struct flow **flows;
282 struct route **routes;
283 struct short_channel_id scid12, scid23;
284 struct sha256 payment_hash;
285 struct amount_msat *amounts;
286 char *errmsg;
287
288 if (!hex_decode("0001020304050607080900010203040506070809000102030405060708090102",
289 strlen("0001020304050607080900010203040506070809000102030405060708090102"),
290 &payment_hash, sizeof(payment_hash)))
291 abort();
292
293 common_setup(argv[0]);
294
295 fd = tmpdir_mkstemp(tmpctx, "run-not_mcf.XXXXXX", &gossfile);
296 tal_add_destructor(gossfile, remove_file);
297 assert(write_all(fd, canned_map, sizeof(canned_map)));
298
299 gossmap = gossmap_load(tmpctx, gossfile, NULL, NULL);
300 assert(gossmap);
301
302 /* There is a public channel 2<->3 (103x1x0), and 1<->2 (110x1x1). */
303 assert(node_id_from_hexstr("0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518", 66, &l1));
304 assert(node_id_from_hexstr("022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59", 66, &l2));
305 assert(node_id_from_hexstr("035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d", 66, &l3));
306 assert(short_channel_id_from_str("110x1x0", 7, &scid12));
307 assert(short_channel_id_from_str("103x1x0", 7, &scid23));
308
309 struct uncertainty *uncertainty = uncertainty_new(tmpctx);
310 int skipped_count = uncertainty_update(uncertainty, gossmap);
311 assert(skipped_count == 0);
312
313 bitmap *disabled = tal_arrz(
314 tmpctx, bitmap, 2 * BITMAP_NWORDS(gossmap_max_chan_idx(gossmap)));
315
316 printf("All set, now let's call minflow ...\n");
317
318 flows = minflow(tmpctx, gossmap,
319 gossmap_find_node(gossmap, &l1),
320 gossmap_find_node(gossmap, &l3),
321 uncertainty_get_chan_extra_map(uncertainty),
322 disabled,
323 /* Half the capacity */
324 AMOUNT_MSAT(500000000),
325 /* max_fee = */ AMOUNT_MSAT(1000000), // 1k sats
326 /* min probability = */ 0.1,
327 /* base probability = */ 1.0,
328 /* delay fee factor = */ 1,
329 /* base fee penalty */ 1,
330 /* prob cost factor = */ 10,
331 &errmsg);
332 printf("minflow completed.\n");

Callers

nothing calls this directly

Calls 15

hex_decodeFunction · 0.85
abortFunction · 0.85
common_setupFunction · 0.85
tmpdir_mkstempFunction · 0.85
uncertainty_newFunction · 0.85
uncertainty_updateFunction · 0.85
gossmap_max_chan_idxFunction · 0.85
gossmap_find_nodeFunction · 0.85
flows_to_routesFunction · 0.85
uncertainty_commit_htlcsFunction · 0.85

Tested by

no test coverage detected