custommsg

custommsg -- Hook for handling custom peer messages

DESCRIPTION

The custommsg hook is the receiving counterpart to the sendcustommsg RPC method and is called whenever a peer sends a custom message that is not handled internally by Core Lightning.

The goal of these two components is to allow the implementation of custom protocols or prototypes on top of a Core Lightning node, without having to change the node's implementation itself.

Messages are restricted to odd-numbered types and must not conflict with internally handled message types.
These limitations are in place in order to avoid conflicts with the internal state tracking, and avoiding disconnections or channel closures, since odd-numbered message can be ignored by nodes (see "it's ok to be odd" in BOLT #1 for details).

Note that if the hook registration specifies "filters" then that should be a JSON array of message numbers, and the hook will only be called for those.
Otherwise, the hook is called for all messages not handled internally. (added in v25.12)

This is a chained hook and MUST return {"result": "continue"}.

HOOK PAYLOAD

  • peer_id (pubkey): The node_id of the peer that sent the message.
  • payload (hex): The raw message payload as a hex string.

The first two bytes encode the message type (big-endian), followed by the message payload.
The plugin must implement the parsing of the message, including the type prefix, since Core Lightning does not know how to parse the message.

HOOK RETURN

  • result (string) (always "continue"): Must always be continue. Any other value will cause the hook to fail.

SEE ALSO

lightning-sendcustommsg(7)

Core Lightning is Blockstream's open-source implementation of the Lightning Network optimised for performance. It is highly customizable through modular expandability.

© 2026 Core Lightning, a Blockstream project.
All rights reserved.

X Twitter Logo Streamline Icon: https://streamlinehq.com

X

The official Core Lightning X(Twitter) handle to follow project updates and announcements.

Github Logo 2 Streamline Icon: https://streamlinehq.com

Github

Github repository for source code, issues, and contributions. Visit our project here to explore or contibute.

Telegram

Community-driven telegram group where most of the node operators hang out. Go to https://t.me/lightningd to join.

Discord

Community-driven discord server where the devs flock together. Go to https://discord.gg/V6ay9yNhBQ to join.