-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugins/recover: Add a plugin to detect we need recovery and it autom…
…atically handles everything.
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ chanbackup | |
commando | ||
sql | ||
cln-renepay | ||
recover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "config.h" | ||
#include <ccan/array_size/array_size.h> | ||
#include <common/features.h> | ||
#include <common/hsm_encryption.h> | ||
#include <common/json_param.h> | ||
#include <common/json_stream.h> | ||
#include <plugins/libplugin.h> | ||
|
||
static bool peer_backup; | ||
|
||
static struct command_result *json_we_lost_state(struct command *cmd, | ||
const char *buf, | ||
const jsmntok_t *params) | ||
{ | ||
|
||
plugin_log(cmd->plugin, LOG_DBG, "RECEIVED WE LOST DATA"); | ||
|
||
return notification_handled(cmd); | ||
} | ||
|
||
|
||
static const char *init(struct plugin *p, | ||
const char *buf UNUSED, | ||
const jsmntok_t *config UNUSED) | ||
{ | ||
u8 *features; | ||
|
||
/* Figure out if they specified --experimental-peer-storage */ | ||
rpc_scan(p, "getinfo", | ||
take(json_out_obj(NULL, NULL, NULL)), | ||
"{our_features:{init:%}}", | ||
JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex, &features)); | ||
peer_backup = feature_offered(features, OPT_WANT_PEER_BACKUP_STORAGE); | ||
|
||
plugin_log(p, LOG_DBG, "Recover Plugin Initialised!"); | ||
|
||
return NULL; | ||
} | ||
|
||
static const struct plugin_notification notifs[] = { | ||
{ | ||
"we_lost_state", | ||
json_we_lost_state, | ||
} | ||
}; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
setup_locale(); | ||
|
||
plugin_main(argv, init, PLUGIN_STATIC, true, NULL, | ||
NULL, 0, | ||
notifs, ARRAY_SIZE(notifs), NULL, 0, | ||
NULL, 0, /* Notification topics we publish */ | ||
NULL); | ||
} |