diff --git a/plugins/chanbackup.c b/plugins/chanbackup.c index c875eaa21a0c..095859b56c66 100644 --- a/plugins/chanbackup.c +++ b/plugins/chanbackup.c @@ -822,6 +822,37 @@ static bool verify_bkp(struct command *cmd, return true; } +static struct command_result *after_fetchscb(struct command *cmd, + const u8 *hexdata, + struct json_stream *response) +{ + u64 version; + u32 timestamp; + struct scb_chan **scb; + + if (tal_bytelen(hexdata) == 0) { + json_add_string(response, "peer_storage", + "Does not exist!"); + return command_finished(cmd, response); + } + + if (!fromwire_static_chan_backup(cmd, + hexdata, + &version, + ×tamp, + &scb)) { + json_add_string(response, "peer_storage", "Corrupted SCB on disk!"); + return command_finished(cmd, response); + } + + if (version != VERSION) { + json_add_string(response,"peer_storage", + "Incompatible version, Contact the admin or update the backup immediately!"); + return command_finished(cmd, response); + } + json_add_bool(response, "peer_storage", true); + return command_finished(cmd, response); +} static struct command_result *json_verifybackup(struct command *cmd, const char *buf, @@ -844,8 +875,11 @@ static struct command_result *json_verifybackup(struct command *cmd, json_add_bool(response, "emergency.recover", true); } - return command_finished(cmd, response); - + return jsonrpc_get_datastore_binary(cmd->plugin, + cmd, + "chanbackup/latestscb", + after_fetchscb, + response); } static const char *init(struct plugin *p,