lightningd: allow sending of even messages.

It's your funeral!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-10-23 22:00:51 +10:30
parent ad7dcf381e
commit bd80af5295
3 changed files with 9 additions and 18 deletions

View file

@ -16,11 +16,9 @@ top, not for direct use by end-users.
The message must be a hex encoded well-formed message, including the 2-byte
type prefix, but excluding the length prefix which will be added by the RPC
method. The messages must not use even-numbered types, since these may require
synchronous handling on the receiving side, and can cause the connection to be
dropped. The message types may also not use one of the internally handled
method. The message types may not be one of the internally handled
types, since that may cause issues with the internal state tracking of
Core Lightning.
Core Lightning. We do (as of *v23.11*) allow sending of even types, but note that peers (as per the spec) will disconnect on receiving unknown even types.
The node specified by `node_id` must be a peer, i.e., it must have a direct
connection with the node receiving the RPC call, and the connection must be
@ -33,7 +31,7 @@ not have a connection, or are synchronous daemons that do not handle
spontaneous messages.
On the reveiving end a plugin may implement the `custommsg` plugin hook and
get notified about incoming messages.
get notified about incoming messages, and allow additional unknown even types in their getmanifest response.
RETURN VALUE
------------

View file

@ -811,13 +811,12 @@ static struct command_result *json_sendcustommsg(struct command *cmd,
}
if (type % 2 == 0) {
return command_fail(
cmd, JSONRPC2_INVALID_REQUEST,
"Cannot send even-typed %d custom message. Currently "
"custom messages are limited to odd-numbered message "
"types, as even-numbered types might result in "
"disconnections.",
type);
/* INFO the first time, then DEBUG */
static enum log_level level = LOG_INFORM;
log_(cmd->ld->log, level, dest, false,
"sendcustommsg id=%s sending a custom even message (%u)",
cmd->id, type);
level = LOG_DBG;
}
peer = peer_by_id(cmd->ld, dest);

View file

@ -2619,12 +2619,6 @@ def test_sendcustommsg(node_factory):
with pytest.raises(RpcError, match=r'Cannot send messages of type 18 .WIRE_PING.'):
l2.rpc.sendcustommsg(l2.info['id'], r'0012')
# The sendcustommsg RPC call is currently limited to odd-typed messages,
# since they will not result in disconnections or even worse channel
# failures.
with pytest.raises(RpcError, match=r'Cannot send even-typed [0-9]+ custom message'):
l2.rpc.sendcustommsg(l2.info['id'], r'00FE')
# This should work since the peer is currently owned by `channeld`
l2.rpc.sendcustommsg(l1.info['id'], msg)
l2.daemon.wait_for_log(