1
0
mirror of https://github.com/ACINQ/eclair.git synced 2024-11-19 01:43:22 +01:00
eclair/docs/MultipartPayments.md
Richard Myers 553727cb22
Convert wiki pages in to files in the docs directory and general docs file cleanups (#2165)
Created new files for pages that were in the wiki, but not already in the docs directory. Also made following fixes to  README.md and existing files in the docs directory:

* update bolt links to avoid redirect
* link to logging guide from logging section (README.md)
* fixed typo in Backup section and capitalization of Bitcoin Core (README.md)
* Alice does not need trampoline feature enabled (TrampolinePayments.md)
* link to 2021 edition of Trampoline PR (TrampolinePayments.md)
* fixed API examples and removed quotes from password (API.md)
* use --nodeIds for sendtoroute examples (TrampolinePayments.md and MultipartPayments.md)
* update CLI example 3 to use jq (Usage.md)
* fix typo in docs/FAQ.md
* updated Guide.md to point to all pages that are guides
2022-02-06 20:28:50 +01:00

2.5 KiB

Multipart Payments

Eclair started supporting multi-part payments in v0.3.3.

Receiving multi-part payments

Once the feature is activated, your eclair node will generate invoices that can be paid using MPP. If the sender also supports MPP, your node will accept the payment. It's as simple as that!

Here is how you generate an invoice:

eclair-cli createinvoice --amountMsat=42000000 --description="MPP is #reckless"

Sending multi-part payments

With the built-in splitting algorithm

If you try paying an invoice that supports MPP, eclair will automatically split the payment (if needed).

You just need to use the payinvoice command, nothing complicated here:

eclair-cli payinvoice --invoice=lnbc11pdkmqhupp5n2e...

However, we are still experimenting with various algorithms to efficiently split payments. You may find that the resulting split looks less optimal that what you expected, in which case the next section is for you!

With your own splitting algorithm

The CLI allows you to fully control how your payment is split and sent. This is a good way to start experimenting with MPP.

Let's imagine that the network looks like this:

  +------- Bob -------+
  |                   |
Alice               Dave 
  |                   |
  +------- Carol -----+

Dave has generated an MPP invoice for 400000 msat: lntb1500n1pwxx94fp....

You want to send 150000 msat through Bob and 250000 msat through Carol.

Initiate the payment by sending the first part:

eclair-cli sendtoroute --amountMsat=150000 --nodeIds=$ALICE_ID,$BOB_ID,$DAVE_ID --finalCltvExpiry=16 --invoice=lntb1500n1pwxx94fp...

This will return some identifiers that must be used for the other parts:

{
  "paymentId": "4e8f2440-dbfd-4e76-bb45-a0647a966b2a",
  "parentId": "cd083b31-5939-46ac-bf90-8ac5b286a9e2"
}

The parentId is important: this is the identifier used to link the parts together.

Now that you have those, you can send the second part:

eclair-cli sendtoroute --parentId=cd083b31-5939-46ac-bf90-8ac5b286a9e2 --amountMsat=250000 --nodeIds=$ALICE_ID,$CAROL_ID,$DAVE_ID --finalCltvExpiry=16 --invoice=lntb1500n1pwxx94fp...

You can then check the status of the payment with the getsentinfo command:

eclair-cli getsentinfo --id=cd083b31-5939-46ac-bf90-8ac5b286a9e2

Once Dave accepts the HTLCs you should see all the details about the payment success (preimage, route, fees, etc).