mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
chanbackup: even if they enable experimental-peer-storage, check peers
Seems like LND is hanging up on receiving these messages, even though they're odd :( So, when a peer connects, check if it supplies or wants peer backup (even if it doesn't support both, it shouldn't hang up, and I didn't want to separate the two paths). And when we go to send our own, updated backup, check features before sending. Fixes: #6065 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-EXPERIMENTAL: `experimental-peer-storage` caused LND to hang up on us, so only send to peers which support it.
This commit is contained in:
committed by
Alex Myers
parent
6c4a438afd
commit
df10c62508
@@ -436,6 +436,9 @@ static struct command_result *after_listpeers(struct command *cmd,
|
|||||||
bool is_connected;
|
bool is_connected;
|
||||||
u8 *serialise_scb;
|
u8 *serialise_scb;
|
||||||
|
|
||||||
|
if (!peer_backup)
|
||||||
|
return notification_handled(cmd);
|
||||||
|
|
||||||
serialise_scb = towire_peer_storage(cmd,
|
serialise_scb = towire_peer_storage(cmd,
|
||||||
get_file_data(tmpctx, cmd->plugin));
|
get_file_data(tmpctx, cmd->plugin));
|
||||||
|
|
||||||
@@ -443,10 +446,20 @@ static struct command_result *after_listpeers(struct command *cmd,
|
|||||||
|
|
||||||
info->idx = 0;
|
info->idx = 0;
|
||||||
json_for_each_arr(i, peer, peers) {
|
json_for_each_arr(i, peer, peers) {
|
||||||
json_to_bool(buf, json_get_member(buf, peer, "connected"),
|
const char *err;
|
||||||
&is_connected);
|
u8 *features;
|
||||||
|
|
||||||
if (is_connected && peer_backup) {
|
/* If connected is false, features is missing, so this fails */
|
||||||
|
err = json_scan(cmd, buf, peer,
|
||||||
|
"{connected:%,features:%}",
|
||||||
|
JSON_SCAN(json_to_bool, &is_connected),
|
||||||
|
JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex,
|
||||||
|
&features));
|
||||||
|
if (err || !is_connected)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* We shouldn't have to check, but LND hangs up? */
|
||||||
|
if (feature_offered(features, OPT_PROVIDE_PEER_BACKUP_STORAGE)) {
|
||||||
const jsmntok_t *nodeid;
|
const jsmntok_t *nodeid;
|
||||||
struct node_id node_id;
|
struct node_id node_id;
|
||||||
|
|
||||||
@@ -533,6 +546,7 @@ static struct command_result *peer_connected(struct command *cmd,
|
|||||||
struct out_req *req;
|
struct out_req *req;
|
||||||
u8 *serialise_scb;
|
u8 *serialise_scb;
|
||||||
const char *err;
|
const char *err;
|
||||||
|
u8 *features;
|
||||||
|
|
||||||
if (!peer_backup)
|
if (!peer_backup)
|
||||||
return command_hook_success(cmd);
|
return command_hook_success(cmd);
|
||||||
@@ -541,8 +555,9 @@ static struct command_result *peer_connected(struct command *cmd,
|
|||||||
get_file_data(tmpctx, cmd->plugin));
|
get_file_data(tmpctx, cmd->plugin));
|
||||||
node_id = tal(cmd, struct node_id);
|
node_id = tal(cmd, struct node_id);
|
||||||
err = json_scan(cmd, buf, params,
|
err = json_scan(cmd, buf, params,
|
||||||
"{peer:{id:%}}",
|
"{peer:{id:%,features:%}}",
|
||||||
JSON_SCAN(json_to_node_id, node_id));
|
JSON_SCAN(json_to_node_id, node_id),
|
||||||
|
JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex, &features));
|
||||||
if (err) {
|
if (err) {
|
||||||
plugin_err(cmd->plugin,
|
plugin_err(cmd->plugin,
|
||||||
"peer_connected hook did not scan %s: %.*s",
|
"peer_connected hook did not scan %s: %.*s",
|
||||||
@@ -550,6 +565,12 @@ static struct command_result *peer_connected(struct command *cmd,
|
|||||||
json_tok_full(buf, params));
|
json_tok_full(buf, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We shouldn't have to check, but LND hangs up? */
|
||||||
|
if (!feature_offered(features, OPT_WANT_PEER_BACKUP_STORAGE)
|
||||||
|
&& !feature_offered(features, OPT_PROVIDE_PEER_BACKUP_STORAGE)) {
|
||||||
|
return command_hook_success(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
req = jsonrpc_request_start(cmd->plugin,
|
req = jsonrpc_request_start(cmd->plugin,
|
||||||
cmd,
|
cmd,
|
||||||
"sendcustommsg",
|
"sendcustommsg",
|
||||||
|
|||||||
Reference in New Issue
Block a user