peer_connected

peer_connected -- Hook fired when a peer connects and completes handshake

DESCRIPTION

The peer_connected hook is called whenever a peer has connected and successfully completed the cryptographic handshake.

This is a chained hook: the first plugin returning "disconnect" stops further processing.
Plugins can call listpeers to retrieve additional information about the peer.

HOOK PAYLOAD

  • peer (object):
    • id (pubkey): The node_id of the connected peer.
    • direction (string) (one of "in", "out"): Connection direction: in for incoming, out for outgoing.
    • addr (string): The addr field shows the address that we are connected to ourselves, not the gossiped list of known addresses.
      In particular this means that the port for incoming connections is an ephemeral port, that may not be available for reconnections.
    • features (hex): Feature bits advertised by the peer, encoded as hex.
    • remote_addr (string, optional): Our own address as reported by the remote peer. Helps with detecting our own IPv4 changes behind NAT.

HOOK RETURN

  • result (string) (one of "continue", "disconnect"): Whether to allow the connection to proceed or disconnect the peer.
  • error_message (string, optional): Optional error message sent to the peer before disconnection.
    Only used if result is "disconnect".

SEE ALSO

lightning-listpeers(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.