Recovers the channels by making RPC to `recoverchannel` */
| 359 | |
| 360 | /* Recovers the channels by making RPC to `recoverchannel` */ |
| 361 | static struct command_result *json_emergencyrecover(struct command *cmd, |
| 362 | const char *buf, |
| 363 | const jsmntok_t *params) |
| 364 | { |
| 365 | struct out_req *req; |
| 366 | u64 version; |
| 367 | u32 timestamp; |
| 368 | bool is_converted; |
| 369 | struct modern_scb_chan **scb_tlvs; |
| 370 | |
| 371 | if (!param(cmd, buf, params, NULL)) |
| 372 | return command_param_failed(); |
| 373 | |
| 374 | u8 *res = decrypt_scb(cmd->plugin); |
| 375 | if (!read_static_chan_backup(cmd, res, &version, ×tamp, &scb_tlvs, &is_converted)) |
| 376 | return command_fail(cmd, LIGHTNINGD, |
| 377 | "Invalid recovery format"); |
| 378 | |
| 379 | if ((version & 0x5555555555555555ULL) != (VERSION & 0x5555555555555555ULL)) { |
| 380 | plugin_err(cmd->plugin, |
| 381 | "Incompatible emergencyrecover version: loaded version %"PRIu64", expected version %"PRIu64". Contact the admin!", version, VERSION); |
| 382 | } |
| 383 | |
| 384 | req = jsonrpc_request_start(cmd, "recoverchannel", |
| 385 | after_recover_rpc, |
| 386 | forward_error, NULL); |
| 387 | |
| 388 | if (is_converted) { |
| 389 | plugin_notify_message(cmd, LOG_DBG, "Processing legacy emergency.recover file format. " |
| 390 | "Please migrate to the latest file format for improved " |
| 391 | "compatibility and fund recovery."); |
| 392 | } |
| 393 | |
| 394 | json_array_start(req->js, "scb"); |
| 395 | for (size_t i=0; i<tal_count(scb_tlvs); i++) { |
| 396 | u8 *scb_hex = tal_arr(cmd, u8, 0); |
| 397 | towire_modern_scb_chan(&scb_hex, scb_tlvs[i]); |
| 398 | json_add_hex_talarr(req->js, NULL, scb_hex); |
| 399 | } |
| 400 | json_array_end(req->js); |
| 401 | |
| 402 | return send_outreq(req); |
| 403 | } |
| 404 | |
| 405 | static void update_scb(struct plugin *p, struct modern_scb_chan **channels) |
| 406 | { |
nothing calls this directly
no test coverage detected