lightning-renepay

lightning-renepay -- Command for sending a payment to a BOLT11 invoice

SYNOPSIS

renepay invstring [amount_msat] [maxfee] [maxdelay] [retry_for] [description] [label] [exclude]

DESCRIPTION

Command added in v23.08.

renepay is a new payment plugin based on Pickhardt-Richter optimization method for Multi-Path-Payments. This implementation has not been thoroughly tested and it should be used with caution.

The response will occur when the payment fails or succeeds. Once a payment has succeeded, calls to renepay with the same invstring will not lead to a new payment attempt, but instead it will succeed immediately.

When using lightning-cli, you may skip optional parameters by using null. Alternatively, use -k option to provide parameters by name.

  • invstring (string): Bolt11 invoice which the RPC command attempts to pay. Currently, renepay supports bolt11 invoices only.
  • amount_msat (msat, optional): If the invstring does not contain an amount, amount_msat is required, otherwise if it is specified it must be null. in millisatoshi precision; it can be a whole number, or a whole number with suffix msat or sat, or a three decimal point number with suffix sat, or an 1 to 11 decimal point number suffixed by btc.
  • maxfee (msat, optional): maxfee is a hard bound, in the sense that the command will never attempt a payment when the fees exceed that value.
  • maxdelay (u32, optional): Overrides the value of max-locktime-blocks for this payment. It serves to limit the locktime of funds in the payment HTLC measured in blocks.
  • retry_for (u32, optional): Measured in seconds specifies how much time it is allowed for the command to keep retrying the payment. The default is 60 seconds.
  • description (string, optional): Only required for bolt11 invoices which do not contain a description themselves, but contain a description hash: in this case description is required. description is then checked against the hash inside the invoice before it will be paid.
  • label (string, optional): Used to attach a label to payments, and is returned in lightning-listpays(7) and lightning-listsendpays(7).
  • exclude (array, optional): exclude is a JSON array of short-channel-id/direction (e.g. [ '564334x877x1/0', '564195x1292x0/1' ]) or pubkey which should be excluded from consideration for routing. The default is not to exclude any channels or nodes. (added v24.08):
    • (short_channel_id_dir)
    • (pubkey)

OPTIMALITY

renepay is based on the work by Pickhardt-Richter's Optimally Reliable & Cheap Payment Flows on the Lightning Network. Which means the payment command will prefer routes that have a higher probability of success while keeping fees low.

The algorithm records some partial knowledge of the state of the Network deduced from the responses obtained after evey payment attempt. This knowledge is kept through different payment requests, but decays with time to account for the dynamics of the Network (after 1 hour all previous knowledge will be erased). Knowledge from previous payment attempts increases the reliability for subsequent ones.

Higher probabilities of success and lower fees cannot generally by optimized at once. Hence renepay combines the two in different amounts seeking solutions that satisfy maxfee bound and a target for 90% probability of success. maxfee is a hard bound, in the sense that the command will never attempt a payment when the fees exceed that value. While the probability target is not compulsory (but desirable), i.e. if the best route does not satisfy the 90% probability target it will be tried anyways.

When maxfee and the 90% probability bounds are satified, the algorithm will optimize the fees to its lowest value.

RANDOMIZATION

To protect user privacy, the payment algorithm performs shadow route randomization. Which means the payment algorithm will virtually extend the route by adding delays and fees along it, making it appear to intermediate nodes that the route is longer than it actually is. This prevents intermediate nodes from reliably guessing their distance from the payee.

Route randomization will never exceed maxfee of the payment. Route randomization and shadow routing will not take routes that would exceed maxdelay.

RETURN VALUE

On success, an object is returned, containing:

  • payment_preimage (secret): The proof of payment: SHA256 of this payment_hash.
  • payment_hash (hash): The hash of the payment_preimage which will prove payment.
  • created_at (number): The UNIX timestamp showing when this payment was initiated.
  • parts (u32): How many attempts this took.
  • amount_msat (msat): Amount the recipient received.
  • amount_sent_msat (msat): Total amount we sent (including fees).
  • status (string) (one of "complete", "pending", "failed"): Status of payment.
  • destination (pubkey, optional): The final destination of the payment.

You can monitor the progress and retries of a payment using the lightning-renepaystatus(7) command.

ERRORS

The following error codes may occur:

  • -1: Catchall nonspecific error.
  • 200: Other payment attempts are in progress.
  • 203: Permanent failure at destination.
  • 205: Unable to find a route.
  • 206: Payment routes are too expensive.
  • 207: Invoice expired. Payment took too long before expiration, or already expired at the time you initiated payment.
  • 210: Payment timed out without a payment in progress.
  • 212: Invoice is invalid.

AUTHOR

Eduardo Quintana-Miranda <[email protected]> is mainly responsible.

SEE ALSO

lightning-renepaystatus(7), lightning-listpays(7), lightning-invoice(7)

RESOURCES

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

Pickhardt R. and Richter S., Optimally Reliable & Cheap Payment Flows on the Lightning Network https://arxiv.org/abs/2107.05322

EXAMPLES

Example 1:

Request:

lightning-cli renepay -k "invstring"="lnbcrt1pn2s3xxsp5xvccgadvepzypat5v8u8tstwdvn9ez4908h7ntl4s0ggx76ug4cqpp50qwurth9swdlzphjvjc2qm8sws8jcu0u28y4vt5s7nhr3js0c3vsdqcdserzgryv4ekxunfwp6xjmmwxqyjw5qcqp9rzjqdwjkyvjm7apxnssu4qgwhfkd67ghs6n6k48v6uqczgt88p6tky96qqqduqqqqgqqqqqqqqpqqqqqzsqqc9qxpqysgqw4qfxj30wqn2m2qmcfz2gs6ttszdhkc0kjqk0mgg59tj2cy90wcke4tjzmzakrkvcgqgf3367j47q5g2ruuw67cxaqxm2t4m42yecsqp92jzs7" "amount_msat"=400000
{
  "id": "example:renepay#1",
  "method": "renepay",
  "params": {
    "invstring": "lnbcrt1pn2s3xxsp5xvccgadvepzypat5v8u8tstwdvn9ez4908h7ntl4s0ggx76ug4cqpp50qwurth9swdlzphjvjc2qm8sws8jcu0u28y4vt5s7nhr3js0c3vsdqcdserzgryv4ekxunfwp6xjmmwxqyjw5qcqp9rzjqdwjkyvjm7apxnssu4qgwhfkd67ghs6n6k48v6uqczgt88p6tky96qqqduqqqqgqqqqqqqqpqqqqqzsqqc9qxpqysgqw4qfxj30wqn2m2qmcfz2gs6ttszdhkc0kjqk0mgg59tj2cy90wcke4tjzmzakrkvcgqgf3367j47q5g2ruuw67cxaqxm2t4m42yecsqp92jzs7",
    "amount_msat": 400000
  }
}

Response:

{
  "bolt11": "lnbcrt1pn2s3xxsp5xvccgadvepzypat5v8u8tstwdvn9ez4908h7ntl4s0ggx76ug4cqpp50qwurth9swdlzphjvjc2qm8sws8jcu0u28y4vt5s7nhr3js0c3vsdqcdserzgryv4ekxunfwp6xjmmwxqyjw5qcqp9rzjqdwjkyvjm7apxnssu4qgwhfkd67ghs6n6k48v6uqczgt88p6tky96qqqduqqqqgqqqqqqqqpqqqqqzsqqc9qxpqysgqw4qfxj30wqn2m2qmcfz2gs6ttszdhkc0kjqk0mgg59tj2cy90wcke4tjzmzakrkvcgqgf3367j47q5g2ruuw67cxaqxm2t4m42yecsqp92jzs7",
  "amount_msat": 400000,
  "payment_hash": "781dc1aee5839bf106f264b0a06cf0740f2c71fc51c9562e90f4ee38ca0fc459",
  "destination": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59",
  "created_at": 1722303718.0730329,
  "groupid": 1,
  "parts": 2,
  "status": "complete",
  "payment_preimage": "af67b48518e78e157db404d13cb42987c31e034634203d10b224302b05fc6c90",
  "amount_sent_msat": 400000
}

Example 2:

Request:

lightning-cli renepay -k "invstring"="lnbcrt40n1pn2s3xxsp5j329vez86jvxw6543zlcla2fusm7v6h74pf7ftmmyfv6zm9uedlspp5j6xpxmq8cwd305vj2dvd6dh4mkr0s6guvehvyleymedgf4vsm3ysdqaveskjmr9vssxgetnvdexjur5d9hkuxqyjw5qcqp9rzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqduqqqqgqqqqqqqqpqqqqqzsqqc9qxpqysgqk6uwy8pkv42jzhdna3z4vxpwkapdzzpn2tcpjnqj738nlpkjc583l9v72vlskt8y33rr4z3jma32xx7ve0jfy7anvn6r98cr5flhcuqqhr4shx"
{
  "id": "example:renepay#2",
  "method": "renepay",
  "params": {
    "invstring": "lnbcrt40n1pn2s3xxsp5j329vez86jvxw6543zlcla2fusm7v6h74pf7ftmmyfv6zm9uedlspp5j6xpxmq8cwd305vj2dvd6dh4mkr0s6guvehvyleymedgf4vsm3ysdqaveskjmr9vssxgetnvdexjur5d9hkuxqyjw5qcqp9rzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqduqqqqgqqqqqqqqpqqqqqzsqqc9qxpqysgqk6uwy8pkv42jzhdna3z4vxpwkapdzzpn2tcpjnqj738nlpkjc583l9v72vlskt8y33rr4z3jma32xx7ve0jfy7anvn6r98cr5flhcuqqhr4shx"
  }
}

Response:

{
  "bolt11": "lnbcrt40n1pn2s3xxsp5j329vez86jvxw6543zlcla2fusm7v6h74pf7ftmmyfv6zm9uedlspp5j6xpxmq8cwd305vj2dvd6dh4mkr0s6guvehvyleymedgf4vsm3ysdqaveskjmr9vssxgetnvdexjur5d9hkuxqyjw5qcqp9rzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqduqqqqgqqqqqqqqpqqqqqzsqqc9qxpqysgqk6uwy8pkv42jzhdna3z4vxpwkapdzzpn2tcpjnqj738nlpkjc583l9v72vlskt8y33rr4z3jma32xx7ve0jfy7anvn6r98cr5flhcuqqhr4shx",
  "amount_msat": 4000,
  "payment_hash": "968c136c07c39b17d1925358dd36f5dd86f8691c666ec27f24de5a84d590dc49",
  "destination": "035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d",
  "created_at": 1722303719.1643083,
  "groupid": 1,
  "parts": 2,
  "status": "complete",
  "payment_preimage": "8815ee921dba644c076f9f879abb520d8539a6913856a439752eaaadff1e21ac",
  "amount_sent_msat": 4000
}