Reads WIRE_STATIC_CHAN_BACKUP and converts from legacy_scb_chan to * modern_scb_chan, if required. */
| 324 | /* Reads WIRE_STATIC_CHAN_BACKUP and converts from legacy_scb_chan to |
| 325 | * modern_scb_chan, if required. */ |
| 326 | static bool read_static_chan_backup(struct command *cmd, |
| 327 | const u8 *blob, |
| 328 | u64 *version, |
| 329 | u32 *timestamp, |
| 330 | struct modern_scb_chan ***scb_tlvs, |
| 331 | bool *is_converted) |
| 332 | { |
| 333 | bool is_tlvs = false; |
| 334 | struct legacy_scb_chan **scb; |
| 335 | |
| 336 | if (!fromwire_static_chan_backup(cmd, |
| 337 | blob, |
| 338 | version, |
| 339 | timestamp, |
| 340 | &scb)) { |
| 341 | is_tlvs = true; |
| 342 | if (!fromwire_static_chan_backup_with_tlvs(cmd, |
| 343 | blob, |
| 344 | version, |
| 345 | timestamp, |
| 346 | scb_tlvs)) { |
| 347 | return false; |
| 348 | } |
| 349 | } |
| 350 | *is_converted = !is_tlvs; |
| 351 | if (!is_tlvs) { |
| 352 | *scb_tlvs = tal_count(scb) ? tal_arr(cmd, struct modern_scb_chan *, tal_count(scb)): NULL; |
| 353 | for (size_t i=0; i < tal_count(scb); i++){ |
| 354 | (*scb_tlvs)[i] = convert_from_legacy(cmd, scb[i]); |
| 355 | } |
| 356 | } |
| 357 | return true; |
| 358 | } |
| 359 | |
| 360 | /* Recovers the channels by making RPC to `recoverchannel` */ |
| 361 | static struct command_result *json_emergencyrecover(struct command *cmd, |
no test coverage detected