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

Function main

devtools/mkencoded.c:16–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16int main(int argc, char *argv[])
17{
18 u8 encoding, *data;
19
20 setup_locale();
21
22 if (argv[1] && streq(argv[1], "--scids")) {
23 argv++;
24 argc--;
25 if (argc < 2)
26 usage();
27 data = tal_arr(NULL, u8, 0);
28 for (size_t i = 2; i < argc; i++) {
29 struct short_channel_id scid;
30 if (!short_channel_id_from_str(argv[i], strlen(argv[i]),
31 &scid))
32 errx(1, "Invalid short_channel_id %s", argv[i]);
33 towire_short_channel_id(&data, scid);
34 }
35 } else {
36 data = tal_hexdata(NULL, argv[2], strlen(argv[2]));
37 if (!data)
38 errx(1, "Invalid hex string %s", argv[2]);
39 }
40 if (!hex_decode(argv[1], strlen(argv[1]), &encoding, sizeof(encoding)))
41 errx(1, "Expected single hex byte not %s", argv[1]);
42
43 if (encoding == ARR_UNCOMPRESSED)
44 printf("%02x%s\n", encoding, tal_hex(NULL, data));
45 else if (encoding == ARR_ZLIB_DEPRECATED) {
46 errx(1, "ZLIB compression deprecated");
47 } else {
48 errx(1, "Unknown encoding %u", encoding);
49 }
50
51 return 0;
52}

Callers

nothing calls this directly

Calls 8

setup_localeFunction · 0.85
errxFunction · 0.85
towire_short_channel_idFunction · 0.85
tal_hexdataFunction · 0.85
hex_decodeFunction · 0.85
tal_hexFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected