Skip to content

Commit

Permalink
lightningd: allow sendcustommsg even if plugins are still processing …
Browse files Browse the repository at this point in the history
…peer_connected.

This is needed for the next patch, which does this from the peer_connected hook!

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Changed: JSON-RPC: `sendcustommsg` can now be called by a plugin from within the `peer_connected` hook.
  • Loading branch information
rustyrussell authored and endothermicdev committed Feb 8, 2023
1 parent c0b898e commit d7bcac2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lightningd/connect_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit d7bcac2

Please sign in to comment.