BOLT 7 - p2p node and channel discovery

2022-03-17 ยท 2 min read


Overview #

  • Node Discovery
    • Nodes advertise their ID, host {oneof: IPv4/6, TORv3}, port
    • Other nodes must be able to open connections with you
  • Channel Discovery
    • Nodes advertise their currently open channels so others can route through them
  • Gossip Messages
    • node_announcement: nodes exchange these for node discovery
    • channel_announcement: nodes exchange these to announce new channels between some nodes. Should only ever be one per channel.
    • channel_update: Advertise updates to a channel. Dissemninated. At least two expected per channel.

short_channel_id: u64 #

  • A compact descriptor pointing to a channel funding tx.
short_channel_id: {
	block_height: u24,
	block_tx_idx: u24,
	tx_output_idx: u16,

node_announcement Message #

node_announcement: {
	features_len: u16,
	features: bytes,
	timestamp: u32,
	rgb_color: (u8, u8, u8),
	alias: [u8; 32],
	addrlen: u16, // serialized length of addresses
	addresses: Vec<AddressDescriptor>,

enum AddressDescriptor {
	Ipv4(addr, port),
	Ipv6(addr, port),
	Torv3(onion_addr, port)

channel_announcement Message #

nodes must prove that there is actually a channel btw node 1 and node 2

  1. prove a funding tx that pays to btc_key_1 and btc_key_2
    1. verify via short_channel_id -> chain lookup
  2. prove node 1 owns btc_key_1
    1. verify btc_sig_1
  3. prove node 2 owns btc_key_2
    1. verify btc_sig_2
  4. prove both node 1 and node 2 agree to this announcement message
    1. verify node_sig_1 and node_sig_2 (signing over the rest of the announcement)
channel_announcement: {
	node_sig_1: sig,
	node_sig_2: sig,
	btc_sig_1: sig,
	btc_sig_2: sig,
	features_len: u16,
	features: bytes,
	node_id_1: pubkey,
	node_id_2: pubkey,
	btc_key_1: pubkey,
	btc_key_2: pubkey,

channel_update Message #

After announcement, each side independently announces their fees, supported features, etc

channel_update: {
	timestamp: u32,
	message_flags: bytes,
	channel_flags: bytes,
	cltv_expiry_delta: u16,
	htlc_min_msat: u64,
	fee_base_msat: u32,
	fee_proportional_mills: u32,
	htlc_max_msat: u64,