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

Function main

devtools/mkquery.c:16–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16int main(int argc, char *argv[])
17{
18 struct bitcoin_blkid chainhash;
19 const tal_t *ctx = tal(NULL, char);
20 const u8 *msg = NULL;
21
22 setup_locale();
23 secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY |
24 SECP256K1_CONTEXT_SIGN);
25
26 if (argc < 3)
27 usage();
28
29 if (!hex_decode(argv[2], strlen(argv[2]), &chainhash, sizeof(chainhash)))
30 errx(1, "Parsing chainhash");
31
32 if (streq(argv[1], "gossip_timestamp_filter")) {
33 if (argc != 5)
34 usage();
35 msg = towire_gossip_timestamp_filter(ctx, &chainhash,
36 strtol(argv[3], NULL, 0),
37 strtol(argv[4], NULL, 0));
38 } else if (streq(argv[1], "query_channel_range")) {
39 struct tlv_query_channel_range_tlvs *tlvs = NULL;
40 if (argc == 5)
41 tlvs = NULL;
42 else if (argc == 6) {
43 tlvs = tlv_query_channel_range_tlvs_new(ctx);
44 tlvs->query_option = tal(tlvs, bigsize_t);
45 *tlvs->query_option = strtol(argv[5], NULL, 0);
46 } else
47 usage();
48 msg = towire_query_channel_range(ctx, &chainhash,
49 strtol(argv[3], NULL, 0),
50 strtol(argv[4], NULL, 0),
51 tlvs);
52 } else if (streq(argv[1], "query_short_channel_ids")) {
53 struct tlv_query_short_channel_ids_tlvs *tlvs = NULL;
54 u8 *encoded;
55
56 if (argc == 4)
57 tlvs = NULL;
58 else if (argc == 6) {
59 tlvs = tlv_query_short_channel_ids_tlvs_new(ctx);
60 tlvs->query_flags = tal(tlvs, struct tlv_query_short_channel_ids_tlvs_query_flags);
61 tlvs->query_flags->encoding_type = strtol(argv[4], NULL, 0);
62 tlvs->query_flags->encoded_query_flags = tal_hexdata(tlvs->query_flags,
63 argv[5], strlen(argv[5]));
64 if (!tlvs->query_flags->encoded_query_flags)
65 usage();
66 } else
67 usage();
68
69 encoded = tal_hexdata(ctx, argv[3], strlen(argv[3]));
70 if (!encoded)
71 usage();
72
73 msg = towire_query_short_channel_ids(ctx, &chainhash, encoded, tlvs);

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected