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

Function json_to_scb_chan

plugins/chanbackup.c:30–56  ·  view source on GitHub ↗

Helper to fetch out SCB from the RPC call */

Source from the content-addressed store, hash-verified

28
29/* Helper to fetch out SCB from the RPC call */
30static bool json_to_scb_chan(const char *buffer,
31 const jsmntok_t *tok,
32 struct scb_chan ***channels)
33{
34 size_t i;
35 const jsmntok_t *t;
36 *channels = tok->size ? tal_arr(tmpctx,
37 struct scb_chan *,
38 tok->size) : NULL;
39
40 json_for_each_arr(i, t, tok) {
41 const u8 *scb_tmp = tal_hexdata(tmpctx,
42 json_strdup(tmpctx,
43 buffer,
44 t),
45 strlen(json_strdup(tmpctx,
46 buffer,
47 t)));
48 size_t scblen_tmp = tal_count(scb_tmp);
49
50 (*channels)[i] = fromwire_scb_chan(tmpctx,
51 &scb_tmp,
52 &scblen_tmp);
53 }
54
55 return true;
56}
57
58/* This writes encrypted static backup in the recovery file */
59static void write_scb(struct plugin *p,

Callers 1

after_staticbackupFunction · 0.85

Calls 2

tal_hexdataFunction · 0.85
json_strdupFunction · 0.50

Tested by

no test coverage detected