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

Function json_getemergencyrecoverdata

plugins/chanbackup.c:1010–1045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1008}
1009
1010static struct command_result *json_getemergencyrecoverdata(struct command *cmd,
1011 const char *buf,
1012 const jsmntok_t *params)
1013{
1014 const u8 *filedata, *decrypted_filedata;
1015 u64 version;
1016 u32 timestamp;
1017 struct modern_scb_chan **scb_tlvs;
1018 bool is_converted;
1019 struct json_stream *response;
1020
1021 if (!param(cmd, buf, params, NULL))
1022 return command_param_failed();
1023
1024 filedata = get_file_data(tmpctx, cmd->plugin);
1025 decrypted_filedata = decrypt_scb(cmd->plugin);
1026
1027 if (!read_static_chan_backup(cmd, decrypted_filedata,
1028 &version,
1029 &timestamp,
1030 &scb_tlvs,
1031 &is_converted))
1032 return command_fail(cmd, LIGHTNINGD, "Invalid emergencyrecover");
1033
1034 response = jsonrpc_stream_success(cmd);
1035 json_add_hex_talarr(response, "filedata", filedata);
1036
1037 // If false, update the emergency.recover file immediately!
1038 json_add_bool(response, "can_create_penalty", !is_converted);
1039 json_array_start(response, "backed_up_channel_ids");
1040 for (int i = 0; i < tal_count(scb_tlvs); i++) {
1041 json_add_channel_id(response, NULL, &scb_tlvs[i]->cid);
1042 }
1043 json_array_end(response);
1044 return command_finished(cmd, response);
1045}
1046
1047static struct command_result *on_commitment_revocation(struct command *cmd,
1048 const char *buf,

Callers

nothing calls this directly

Calls 13

get_file_dataFunction · 0.85
decrypt_scbFunction · 0.85
read_static_chan_backupFunction · 0.85
json_add_hex_talarrFunction · 0.85
json_add_boolFunction · 0.85
json_array_startFunction · 0.85
json_add_channel_idFunction · 0.85
json_array_endFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70

Tested by

no test coverage detected