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

Function json_to_scb_chan

plugins/chanbackup.c:111–137  ·  view source on GitHub ↗

Helper to fetch out SCB from the RPC call */

Source from the content-addressed store, hash-verified

109
110/* Helper to fetch out SCB from the RPC call */
111static bool json_to_scb_chan(const char *buffer,
112 const jsmntok_t *tok,
113 struct modern_scb_chan ***channels)
114{
115 size_t i;
116 const jsmntok_t *t;
117 *channels = tok->size ? tal_arr(tmpctx,
118 struct modern_scb_chan *,
119 tok->size) : NULL;
120
121 json_for_each_arr(i, t, tok) {
122 const u8 *scb_tmp = tal_hexdata(tmpctx,
123 json_strdup(tmpctx,
124 buffer,
125 t),
126 strlen(json_strdup(tmpctx,
127 buffer,
128 t)));
129 size_t scblen_tmp = tal_count(scb_tmp);
130
131 (*channels)[i] = fromwire_modern_scb_chan(tmpctx,
132 &scb_tmp,
133 &scblen_tmp);
134 }
135
136 return true;
137}
138
139/* This writes encrypted static backup in the recovery file */
140static 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