From d7bcac2ae740c87e40d4daa2aba754ed7d853dd3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 2 Feb 2023 14:26:10 +1030 Subject: [PATCH] lightningd: allow sendcustommsg even if plugins are still processing peer_connected. This is needed for the next patch, which does this from the peer_connected hook! Signed-off-by: Rusty Russell Changelog-Changed: JSON-RPC: `sendcustommsg` can now be called by a plugin from within the `peer_connected` hook. --- lightningd/connect_control.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index ca50c7c42d32..1632e0387128 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -779,11 +779,11 @@ static struct command_result *json_sendcustommsg(struct command *cmd, type_to_string(cmd, struct node_id, dest)); } - if (peer->connected != PEER_CONNECTED) + /* We allow messages from plugins responding to peer_connected hook, + * so can be PEER_CONNECTING. */ + if (peer->connected == PEER_DISCONNECTED) return command_fail(cmd, JSONRPC2_INVALID_REQUEST, - "Peer is %s", - peer->connected == PEER_DISCONNECTED - ? "not connected" : "still connecting"); + "Peer is not connected"); subd_send_msg(cmd->ld->connectd, take(towire_connectd_custommsg_out(cmd, dest, msg)));