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

Function init

plugins/commando.c:925–968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

923#endif
924
925static const char *init(struct plugin *p,
926 const char *buf UNUSED, const jsmntok_t *config UNUSED)
927{
928 struct secret rune_secret;
929
930 outgoing_commands = tal_arr(p, struct commando *, 0);
931 incoming_commands = tal_arr(p, struct commando *, 0);
932 usage_table_init(&usage_table);
933 plugin = p;
934#if DEVELOPER
935 plugin_set_memleak_handler(p, memleak_mark_globals);
936#endif
937
938 rune_counter = tal(p, u64);
939 if (!rpc_scan_datastore_str(plugin, "commando/rune_counter",
940 JSON_SCAN(json_to_u64, rune_counter)))
941 rune_counter = tal_free(rune_counter);
942
943 /* Old python commando used to store secret */
944 if (!rpc_scan_datastore_hex(plugin, "commando/secret",
945 JSON_SCAN(json_to_secret, &rune_secret))) {
946 rpc_scan(plugin, "makesecret",
947 /* $ i commando
948 * 99 0x63 0143 0b1100011 'c'
949 * 111 0x6F 0157 0b1101111 'o'
950 * 109 0x6D 0155 0b1101101 'm'
951 * 109 0x6D 0155 0b1101101 'm'
952 * 97 0x61 0141 0b1100001 'a'
953 * 110 0x6E 0156 0b1101110 'n'
954 * 100 0x64 0144 0b1100100 'd'
955 * 111 0x6F 0157 0b1101111 'o'
956 */
957 take(json_out_obj(NULL, "hex", "636F6D6D616E646F")),
958 "{secret:%}",
959 JSON_SCAN(json_to_secret, &rune_secret));
960 }
961
962 master_rune = rune_new(plugin, rune_secret.data, ARRAY_SIZE(rune_secret.data),
963 NULL);
964
965 /* Start flush timer. */
966 flush_usage_table(NULL);
967 return NULL;
968}
969
970static const struct plugin_command commands[] = { {
971 "commando",

Callers

nothing calls this directly

Calls 8

rpc_scan_datastore_strFunction · 0.85
tal_freeFunction · 0.85
rpc_scan_datastore_hexFunction · 0.85
rpc_scanFunction · 0.85
json_out_objFunction · 0.85
rune_newFunction · 0.85
flush_usage_tableFunction · 0.85

Tested by

no test coverage detected