| 1008 | } |
| 1009 | |
| 1010 | static 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 | ×tamp, |
| 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 | |
| 1047 | static struct command_result *on_commitment_revocation(struct command *cmd, |
| 1048 | const char *buf, |
nothing calls this directly
no test coverage detected