Recovers the channels by making RPC to `recoverchannel` */
| 236 | |
| 237 | /* Recovers the channels by making RPC to `recoverchannel` */ |
| 238 | static 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 | ×tamp, |
| 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 | |
| 280 | static void update_scb(struct plugin *p, struct scb_chan **channels) |
| 281 | { |
nothing calls this directly
no test coverage detected