Skip to content

Instantly share code, notes, and snippets.

@urza
Last active April 11, 2023 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urza/9400275480f3ea05c8e6d2421527d550 to your computer and use it in GitHub Desktop.
Save urza/9400275480f3ea05c8e6d2421527d550 to your computer and use it in GitHub Desktop.
CLN (Core Lightning)

show list of open channels, their id, short id and remote node alias

#!/bin/bash

lightning-cli listpeers | jq -r '.peers[] | select(.channels != null) | .id' | while read -r id; do
  channel_info=$(lightning-cli listpeers "$id" | jq -r ".peers[0].channels[] | {id: \"${id}\", short_channel_id: .short_channel_id}")
  alias=$(lightning-cli listnodes "$id" | jq -r ".nodes[0].alias")
  echo "$channel_info" | jq --arg alias "$alias" '. + {alias: $alias}'
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment