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

Function json_emergencyrecover

plugins/chanbackup.c:238–278  ·  view source on GitHub ↗

Recovers the channels by making RPC to `recoverchannel` */

Source from the content-addressed store, hash-verified

236
237/* Recovers the channels by making RPC to `recoverchannel` */
238static struct command_result *json_emergencyrecover(struct command *cmd,
239 const char *buf,
240 const jsmntok_t *params)
241{
242 struct out_req *req;
243 u64 version;
244 u32 timestamp;
245 struct scb_chan **scb;
246
247 if (!param(cmd, buf, params, NULL))
248 return command_param_failed();
249
250 u8 *res = decrypt_scb(cmd->plugin);
251
252 if (!fromwire_static_chan_backup(cmd,
253 res,
254 &version,
255 &timestamp,
256 &scb)) {
257 plugin_err(cmd->plugin, "Corrupted SCB!");
258 }
259
260 if (version != VERSION) {
261 plugin_err(cmd->plugin,
262 "Incompatible version, Contact the admin!");
263 }
264
265 req = jsonrpc_request_start(cmd->plugin, cmd, "recoverchannel",
266 after_recover_rpc,
267 &forward_error, NULL);
268
269 json_array_start(req->js, "scb");
270 for (size_t i=0; i<tal_count(scb); i++) {
271 u8 *scb_hex = tal_arr(cmd, u8, 0);
272 towire_scb_chan(&scb_hex,scb[i]);
273 json_add_hex(req->js, NULL, scb_hex, tal_bytelen(scb_hex));
274 }
275 json_array_end(req->js);
276
277 return send_outreq(cmd->plugin, req);
278}
279
280static void update_scb(struct plugin *p, struct scb_chan **channels)
281{

Callers

nothing calls this directly

Calls 10

decrypt_scbFunction · 0.85
json_add_hexFunction · 0.85
tal_bytelenFunction · 0.85
command_param_failedFunction · 0.70
plugin_errFunction · 0.70
send_outreqFunction · 0.70
paramFunction · 0.50
json_array_startFunction · 0.50
towire_scb_chanFunction · 0.50
json_array_endFunction · 0.50

Tested by

no test coverage detected