{
  "$schema": "../rpc-schema-draft.json",
  "type": "object",
  "rpc": "listchannels",
  "title": "Command to query active lightning channels in the entire network",
  "description": [
    "The **listchannels** RPC command returns data on channels that are known to the node. Because channels may be bidirectional, up to 2 objects will be returned for each channel (one for each direction).",
    "",
    "Only one of *short_channel_id*, *source* or *destination* can be supplied. If nothing is supplied, data on all lightning channels known to this node, are returned. These can be local channels or public channels broadcast on the gossip network."
  ],
  "categories": [
    "readonly"
  ],
  "request": {
    "required": [],
    "additionalProperties": false,
    "properties": {
      "short_channel_id": {
        "type": "short_channel_id",
        "description": [
          "If short_channel_id is a short channel id, then only known channels with a matching short_channel_id are returned. Otherwise, it must be null."
        ]
      },
      "source": {
        "type": "pubkey",
        "description": [
          "If source is a node id, then only channels leading from that node id are returned."
        ]
      },
      "destination": {
        "type": "pubkey",
        "description": [
          "If destination is a node id, then only channels leading to that node id are returned."
        ]
      }
    }
  },
  "response": {
    "required": [
      "channels"
    ],
    "additionalProperties": false,
    "properties": {
      "channels": {
        "type": "array",
        "items": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "source",
            "destination",
            "short_channel_id",
            "direction",
            "public",
            "amount_msat",
            "message_flags",
            "channel_flags",
            "active",
            "last_update",
            "base_fee_millisatoshi",
            "fee_per_millionth",
            "delay",
            "htlc_minimum_msat",
            "features"
          ],
          "properties": {
            "source": {
              "type": "pubkey",
              "description": [
                "The source node."
              ]
            },
            "destination": {
              "type": "pubkey",
              "description": [
                "The destination node."
              ]
            },
            "short_channel_id": {
              "type": "short_channel_id",
              "description": [
                "Short channel id of channel."
              ]
            },
            "direction": {
              "type": "u32",
              "description": [
                "Direction (0 if source < destination, 1 otherwise)."
              ]
            },
            "public": {
              "type": "boolean",
              "description": [
                "True if this is announced (from *v24.02*, being false is deprecated)."
              ]
            },
            "amount_msat": {
              "type": "msat",
              "description": [
                "The total capacity of this channel (always a whole number of satoshis)."
              ]
            },
            "message_flags": {
              "type": "u8",
              "description": [
                "As defined by BOLT #7."
              ]
            },
            "channel_flags": {
              "type": "u8",
              "description": [
                "As defined by BOLT #7."
              ]
            },
            "active": {
              "type": "boolean",
              "description": [
                "True unless source has disabled it (or (deprecated in *v24.02*) it's a local channel and the peer is disconnected or it's still opening or closing)."
              ]
            },
            "last_update": {
              "type": "u32",
              "description": [
                "UNIX timestamp on the last channel_update from *source*."
              ]
            },
            "base_fee_millisatoshi": {
              "type": "u32",
              "description": [
                "Base fee changed by *source* to use this channel."
              ]
            },
            "fee_per_millionth": {
              "type": "u32",
              "description": [
                "Proportional fee changed by *source* to use this channel, in parts-per-million."
              ]
            },
            "delay": {
              "type": "u32",
              "description": [
                "The number of blocks delay required by *source* to use this channel."
              ]
            },
            "htlc_minimum_msat": {
              "type": "msat",
              "description": [
                "The smallest payment *source* will allow via this channel."
              ]
            },
            "htlc_maximum_msat": {
              "type": "msat",
              "description": [
                "The largest payment *source* will allow via this channel."
              ]
            },
            "features": {
              "type": "hex",
              "description": [
                "BOLT #9 features bitmap for this channel."
              ]
            }
          }
        }
      }
    },
    "post_return_value_notes": [
      "If one of *short_channel_id*, *source* or *destination* is supplied and no matching channels are found, a 'channels' object with an empty list is returned."
    ]
  },
  "errors": [
    "On error the returned object will contain `code` and `message` properties, with `code` being one of the following:",
    "",
    "- -32602: If the given parameters are wrong."
  ],
  "author": [
    "Michael Hawkins [michael.hawkins@protonmail.com](mailto:michael.hawkins@protonmail.com)."
  ],
  "see_also": [
    "lightning-fundchannel(7)",
    "lightning-listnodes(7)"
  ],
  "resources": [
    "Main web site: [https://github.com/ElementsProject/lightning](https://github.com/ElementsProject/lightning)",
    "",
    "BOLT #7: [https://github.com/lightning/bolts/blob/master/07-routing-gossip.md](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md)"
  ],
  "examples": [
    {
      "request": {
        "id": "example:listchannels#1",
        "method": "listchannels",
        "params": {
          "short_channel_id": "109x1x1"
        }
      },
      "response": {
        "channels": [
          {
            "source": "nodeid020202020202020202020202020202020202020202020202020202020202",
            "destination": "nodeid010101010101010101010101010101010101010101010101010101010101",
            "short_channel_id": "109x1x1",
            "direction": 0,
            "public": true,
            "amount_msat": 1000000000,
            "message_flags": 1,
            "channel_flags": 0,
            "active": true,
            "last_update": 1738500000,
            "base_fee_millisatoshi": 1,
            "fee_per_millionth": 10,
            "delay": 6,
            "htlc_minimum_msat": 0,
            "htlc_maximum_msat": 990000000,
            "features": ""
          },
          {
            "source": "nodeid010101010101010101010101010101010101010101010101010101010101",
            "destination": "nodeid020202020202020202020202020202020202020202020202020202020202",
            "short_channel_id": "109x1x1",
            "direction": 1,
            "public": true,
            "amount_msat": 1000000000,
            "message_flags": 1,
            "channel_flags": 1,
            "active": false,
            "last_update": 1738510000,
            "base_fee_millisatoshi": 1,
            "fee_per_millionth": 10,
            "delay": 6,
            "htlc_minimum_msat": 0,
            "htlc_maximum_msat": 990000000,
            "features": ""
          }
        ]
      }
    },
    {
      "request": {
        "id": "example:listchannels#2",
        "method": "listchannels",
        "params": {}
      },
      "response": {
        "channels": [
          {
            "source": "nodeid020202020202020202020202020202020202020202020202020202020202",
            "destination": "nodeid010101010101010101010101010101010101010101010101010101010101",
            "short_channel_id": "109x1x1",
            "direction": 0,
            "public": true,
            "amount_msat": 1000000000,
            "message_flags": 1,
            "channel_flags": 0,
            "active": true,
            "last_update": 1738500000,
            "base_fee_millisatoshi": 1,
            "fee_per_millionth": 10,
            "delay": 6,
            "htlc_minimum_msat": 0,
            "htlc_maximum_msat": 990000000,
            "features": ""
          },
          {
            "source": "nodeid010101010101010101010101010101010101010101010101010101010101",
            "destination": "nodeid020202020202020202020202020202020202020202020202020202020202",
            "short_channel_id": "109x1x1",
            "direction": 1,
            "public": true,
            "amount_msat": 1000000000,
            "message_flags": 1,
            "channel_flags": 1,
            "active": false,
            "last_update": 1738510000,
            "base_fee_millisatoshi": 1,
            "fee_per_millionth": 10,
            "delay": 6,
            "htlc_minimum_msat": 0,
            "htlc_maximum_msat": 990000000,
            "features": ""
          },
          {
            "source": "nodeid020202020202020202020202020202020202020202020202020202020202",
            "destination": "nodeid030303030303030303030303030303030303030303030303030303030303",
            "short_channel_id": "123x1x1",
            "direction": 0,
            "public": true,
            "amount_msat": 1000000000,
            "message_flags": 1,
            "channel_flags": 2,
            "active": true,
            "last_update": 1738520000,
            "base_fee_millisatoshi": 1,
            "fee_per_millionth": 10,
            "delay": 6,
            "htlc_minimum_msat": 0,
            "htlc_maximum_msat": 990000000,
            "features": ""
          },
          {
            "source": "nodeid030303030303030303030303030303030303030303030303030303030303",
            "destination": "nodeid020202020202020202020202020202020202020202020202020202020202",
            "short_channel_id": "123x1x1",
            "direction": 1,
            "public": true,
            "amount_msat": 1000000000,
            "message_flags": 1,
            "channel_flags": 3,
            "active": false,
            "last_update": 1738530000,
            "base_fee_millisatoshi": 1,
            "fee_per_millionth": 10,
            "delay": 6,
            "htlc_minimum_msat": 0,
            "htlc_maximum_msat": 990000000,
            "features": ""
          },
          {
            "source": "nodeid030303030303030303030303030303030303030303030303030303030303",
            "destination": "nodeid040404040404040404040404040404040404040404040404040404040404",
            "short_channel_id": "130x1x1",
            "direction": 0,
            "public": true,
            "amount_msat": 1000000000,
            "message_flags": 1,
            "channel_flags": 2,
            "active": true,
            "last_update": 1738540000,
            "base_fee_millisatoshi": 1,
            "fee_per_millionth": 10,
            "delay": 6,
            "htlc_minimum_msat": 0,
            "htlc_maximum_msat": 990000000,
            "features": ""
          }
        ]
      }
    }
  ]
}
