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 <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: `sendcustommsg` can now be called by a plugin from within the `peer_connected` hook.
This commit is contained in:
Rusty Russell
2023-02-02 14:26:10 +10:30
committed by Alex Myers
parent c0b898e860
commit d7bcac2ae7

View File

@@ -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)));