-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trampoline/MPP API changes #1297
Conversation
Let a sender manually split a payment and specify a trampoline route.
I'm seeing a few rare failures in those tests in the CI. Adding more output to the assertions will help troubleshoot those. Fix two flaky tests where the order of payment parts could be different, resulting in a failed equality test.
Codecov Report
@@ Coverage Diff @@
## master #1297 +/- ##
==========================================
+ Coverage 77.33% 78.15% +0.82%
==========================================
Files 144 144
Lines 10095 10412 +317
Branches 399 416 +17
==========================================
+ Hits 7807 8138 +331
+ Misses 2288 2274 -14
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice update to the API but there is something unclear to me: does the caller have the ability to select how to split the payment into parts? Because i see the amount
interacting with recipientAmount
(which is the final amount of the invoice) but the caller can only specify one amount
which seem to force all subpart payments have the same amount.
externalId_opt match { | ||
case Some(externalId) if externalId.length > externalIdMaxLength => Future.failed(new IllegalArgumentException("externalId is too long: cannot exceed 66 characters")) | ||
case _ => (appKit.paymentInitiator ? SendPaymentRequest(amount, paymentHash, route.last, 1, finalCltvExpiryDelta, invoice_opt, externalId_opt, route)).mapTo[UUID] | ||
override def sendToRoute(amount: MilliSatoshi, recipientAmount_opt: Option[MilliSatoshi], externalId_opt: Option[String], parentId_opt: Option[UUID], invoice: PaymentRequest, finalCltvExpiryDelta: CltvExpiryDelta, route: Seq[PublicKey], trampolineSecret_opt: Option[ByteVector32], trampolineFees_opt: Option[MilliSatoshi], trampolineExpiryDelta_opt: Option[CltvExpiryDelta], trampolineNodes_opt: Seq[PublicKey])(implicit timeout: Timeout): Future[SendPaymentToRouteResponse] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of functions with so many parameters (this one has 11) but i'm not sure if we can do better here, maybe a small encapsulating case class that names the trampoline parameters i.e TrampolineParams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't really know how to deal with that. The API does require a lot of parameters when you want to do trampoline + MPP.
My view at the moment is that the Eclair
trait reflects the plain API parameters and its job is to convert to something nice for the payment initiator.
I don't know if we want to move that grouping to the Service.scala
or not...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see a big advantage to moving all those args to a case class constructor.
Yes the goal here is that the caller makes one call per payment part. alice-eclair-cli sendtoroute --amountMsat=170060000 --route=$ALICE_ID,$BOB_ID --trampolineNodes=$BOB_ID,$DAVE_ID --trampolineFeesMsat=100000 --trampolineCltvExpiry=144 --finalCltvExpiry=16 --invoice=$INVOICE
alice-eclair-cli sendtoroute --amountMsat=140040000 --parentId=$PARENT_ID --trampolineSecret=$SECRET --route=$ALICE_ID,$BOB_ID --trampolineNodes=$BOB_ID,$DAVE_ID --trampolineFeesMsat=100000 --trampolineCltvExpiry=144 --finalCltvExpiry=16 --invoice=$INVOICE |
I have example scripts at https://github.com/t-bast/lightning-cfg and I'm about to push new ones that use the new API with MPP/Trampoline. |
Nice, so i suppose if the caller doesn't want to use MPP it would just omit the |
As discussed offline, a probably good future way of doing this would be to create stateful APIs for MPP and Trampoline. The user would do something like: > start-mpp-session
{ "paymentId":"id1", "paymentSecret":"s1" }
> send-shard --paymentId=id1 --route=...
> send-shard --paymentId=id1 --route=...
> end-mpp-session But this is quite a lot of re-work of the API, so it's probably something we would do in a second version, once we get user feedback (if we have enough users that want to use the CLI to do MPP or Trampoline). |
I have a note to update the documentation and API once we release the new eclair-core version :) |
If we're relaying multiple HTLCs for the same payment_hash, we need to list all of those. The previous code only handled that when Trampoline was used.
I added a small fix for an issue that I just spotted related to relaying MPP without Trampoline. |
Update the API to allow users to easily use MPP and/or Trampoline.
Note that the second commit is completely unrelated: it fixes a small race condition in an E2E test and adds debug output (see commit message).