Closed hieblmi closed 2 months ago
That's also my understanding, we can't cancel the payment once the htlc is sent. Here, additionally to the existent timeout check that interrupts the payment loop on expiry, we pass in a context (from the rpc server client stream) that is checked for cancellation and interrupts the payment loop if the user cancelled the stream context(Ctrl+C'd the sendpayment from cli). This can only happen if a p.sendAttempt(attempt)
completed.
[!IMPORTANT]
Review skipped
Auto reviews are limited to specific labels.
Labels to auto review (1)
* llm-reviewPlease check the settings in the CodeRabbit UI or the
.coderabbit.yaml
file in this repository. To trigger a single review, invoke the@coderabbitai review
command.You can disable this status message by setting the
reviews.review_status
tofalse
in the CodeRabbit configuration file.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Thanks to the reviewers so far. I think I addressed all your concerns, namely:
cacelable
flag to the SendPaymentRequest
that preserves the current behavior of a long running payment loop even if the stream context is canceled, but cancels the payment loop if set to true.SendPaymentRequest
.payment_lifecycle.go
in favor of the new timeout context.I tested different scenarios locally and didn't encounter an error, additionally to the added test.
Looking forward to another round of feedback.
Just merged the PR that fixed the itest, could you do a rebase and let it run again, thanks!
There still seems to be an unrelated error left: https://github.com/lightningnetwork/lnd/actions/runs/9501738226/job/26188011967?pr=8734#step:6:468
EDIT: Seems to be a flake which is not appearing in the latest.
Fixes https://github.com/lightningnetwork/lnd/issues/8534.
While interrupting
lncli estimateroutefee
ends the client program, the route server is left behind with an abandoned payment loop.To allow users to cancel payment requests properly, the payment loop in
resumePayment
has to be abandoned as well as soon as the user request it. https://github.com/lightningnetwork/lnd/blob/f523f52ab468915d9cf6e18632f17ba707906284/routing/payment_lifecycle.go#L170This PR makes the
SendPaymentV2
streaming context accessible from the payment loop and allows it to safely end if the context was cancelled.