---
updatedAt: 2026-10-26T18:07:10.000Z
agentTools:
  projectIndex: https://docs.corelightning.org/llms.txt
---

# getroutes

# getroutes -- Command for routing a payment

## SYNOPSIS

**getroutes** *source* *destination* *amount\_msat* *layers* *maxfee\_msat* *final\_cltv* \[*maxdelay*] \[*maxparts*] \[*maxhops*]

## DESCRIPTION

Command *added* in v24.08.

The **getroutes** RPC command attempts to find the best set of paths for the payment from *source* to *destination* of *amount\_msat*, using the given *layers* on top of the gossip information.  The result is constrained by *maxfee*, and will arrive at the destination with *final\_cltv*.

NOTE: The returned paths are a different format then *getroute*, being more appropriate for creating intermediary onion layers.

Layers are generally maintained by plugins, either to contain persistent information about capacities which have been discovered, or to contain transient information for this particular payment (such as blinded paths or routehints).

There are some automatic layers: *auto.localchans* contains information on local channels from this node (including non-public ones), and their exact current spendable capacities. *auto.sourcefree* overrides all channels (including those from previous layers) leading out of the *source* to be zero fee and zero delay.  These are both useful in the case where the source is the current node.  *auto.include\_fees* that fixes the send amount and deducts fee from there, ie. the receiver pays for fees instead of the sender.  *auto.no\_mpp\_support* is deprecated in v26.06: use `maxparts=1` instead.

* **source** (pubkey): Node pubkey to start the paths
* **destination** (pubkey): Node pubkey to end the paths
* **amount\_msat** (msat): Amount to send. It can be a whole number, or a whole number ending in *msat* or *sat*, or a number with three decimal places ending in *sat*, or a number with 1 to 11 decimal places ending in *btc*.
* **layers** (array of strings):
  * (string, optional): Layer to apply to the gossip map before attempting to find routes.
* **maxfee\_msat** (msat): Maximum fee to spend: we will never return a set of routes more expensive than this. It can be a whole number, or a whole number ending in *msat* or *sat*, or a number with three decimal places ending in *sat*, or a number with 1 to 11 decimal places ending in *btc*.
* **final\_cltv** (u32): Number of blocks for the final node.  We need to know this because no HTLC is allowed to have a CLTV delay more than 2016 blocks.
* **maxdelay** (u32, optional): Maximum number of blocks of delay for the route. Cannot be bigger than 2016. The default is 2016. *(added v25.02)*
* **maxparts** (u32, optional): Maximum number of routes in the solution. The default is 100. *(added v25.09)*
* **maxhops** (u32, optional): Maximum number of hops for every path. The default is 100. *(added v26.12)*

## RETURN VALUE

On success, an object is returned, containing:

* **probability\_ppm** (u64): The estimated probability of success using these routes, in millionths.
* **routes** (array of objects):
  * **probability\_ppm** (u64): The estimated probability of success using this route, in millionths.
  * **amount\_msat** (msat): The amount delivered to the *destination* by this path.
  * **final\_cltv** (u32): Number of blocks required by the final node (set by caller)
  * **path** (array of objects): The hops to get from *source* to *destination*.:
    * **short\_channel\_id\_dir** (short\_channel\_id\_dir): The channel and direction joining these nodes.
    * **amount\_in\_msat** (msat): The amount to send into this hop. *(added v26.06)*
    * **amount\_out\_msat** (msat): The amount which arrives at the far end of this hop. *(added v26.06)*
    * **node\_id\_in** (pubkey): The peer id at the start of this hop. *(added v26.06)*
    * **node\_id\_out** (pubkey): The peer id at the end of this hop. *(added v26.06)*
    * **cltv\_in** (u32): The total CLTV expected by the node at the start of this hop. *(added v26.06)*
    * **cltv\_out** (u32): The total CLTV expected by the node at the end of this hop. *(added v26.06)*
    * **amount\_msat** (msat, optional): The amount to send into this hop. **deprecated in v26.06, removed after v27.06**
    * **next\_node\_id** (pubkey, optional): The peer id at the end of this hop. **deprecated in v26.06, removed after v27.06**
    * **delay** (u32, optional): The total CLTV expected by the node at the start of this hop. **deprecated in v26.06, removed after v27.06**

## ERRORS

The following error codes may occur:

* -1: Catchall nonspecific error.
* 205: Unable to find a route.
* 206: Route too expensive. Either the max\_delay or maxfee\_msat was exceeded.
* 215: We don't have enough funds in all our channels to pay this.
* 217: The given *maxdelay* is larger than the maximum allowed.
* 220: We can't find sufficient capacity into the destination.

## AUTHOR

<lagrang3@protonmail.com> wrote the minimum-cost-flow solver, Rusty Russell <rusty@rustcorp.com.au> wrote the API and this documentation.

## SEE ALSO

lightning-askrene-reserve(7), lightning-askrene-unreserve(7), lightning-askrene-disable-node(7), lightning-askrene-create-channel(7), lightning-askrene-inform-channel(7), lightning-askrene-report(7), lightning-askrene-age(7)

## RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

## EXAMPLES

**Example 1**:

Request:

```shell
lightning-cli getroutes -k "source"="038194b5f32bdf0aa59812c86c4ef7ad2f294104fa027d1ace9b469bb6f88cf37b" "destination"="03cecbfdc68544cc596223b68ce0710c9e5d2c9cb317ee07822d95079acc703d31" "amount_msat"=1250000 "layers"='[]' "maxfee_msat"=125000 "final_cltv"=0
```
```json
{
  "id": "example:getroutes#1",
  "method": "getroutes",
  "params": {
    "source": "038194b5f32bdf0aa59812c86c4ef7ad2f294104fa027d1ace9b469bb6f88cf37b",
    "destination": "03cecbfdc68544cc596223b68ce0710c9e5d2c9cb317ee07822d95079acc703d31",
    "amount_msat": 1250000,
    "layers": [],
    "maxfee_msat": 125000,
    "final_cltv": 0
  }
}
```

Response:

```json
{
  "probability_ppm": 997501,
  "routes": [
    {
      "probability_ppm": 997501,
      "amount_msat": 1250000,
      "final_cltv": 0,
      "path": [
        {
          "short_channel_id_dir": "116x1x1/1",
          "node_id_in": "038194b5f32bdf0aa59812c86c4ef7ad2f294104fa027d1ace9b469bb6f88cf37b",
          "node_id_out": "033845802d25b4e074ccfd7cd8b339a41dc75bf9978a034800444b51d42b07799a",
          "amount_in_msat": 1250026,
          "amount_out_msat": 1250013,
          "cltv_in": 12,
          "cltv_out": 6,
          "next_node_id": "033845802d25b4e074ccfd7cd8b339a41dc75bf9978a034800444b51d42b07799a",
          "amount_msat": 1250026,
          "delay": 12
        },
        {
          "short_channel_id_dir": "130x1x0/0",
          "node_id_in": "033845802d25b4e074ccfd7cd8b339a41dc75bf9978a034800444b51d42b07799a",
          "node_id_out": "03cecbfdc68544cc596223b68ce0710c9e5d2c9cb317ee07822d95079acc703d31",
          "amount_in_msat": 1250013,
          "amount_out_msat": 1250000,
          "cltv_in": 6,
          "cltv_out": 0,
          "next_node_id": "03cecbfdc68544cc596223b68ce0710c9e5d2c9cb317ee07822d95079acc703d31",
          "amount_msat": 1250013,
          "delay": 6
        }
      ]
    }
  ]
}
```