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

Function read_static_chan_backup

plugins/chanbackup.c:326–358  ·  view source on GitHub ↗

Reads WIRE_STATIC_CHAN_BACKUP and converts from legacy_scb_chan to * modern_scb_chan, if required. */

Source from the content-addressed store, hash-verified

324/* Reads WIRE_STATIC_CHAN_BACKUP and converts from legacy_scb_chan to
325 * modern_scb_chan, if required. */
326static 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` */
361static struct command_result *json_emergencyrecover(struct command *cmd,

Callers 5

json_emergencyrecoverFunction · 0.85
store_latest_scbFunction · 0.85
after_latestscbFunction · 0.85
initFunction · 0.85

Calls 1

convert_from_legacyFunction · 0.85

Tested by

no test coverage detected