Skip to content
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

Send to channel route #1537

Merged
merged 4 commits into from
Oct 8, 2020
Merged

Send to channel route #1537

merged 4 commits into from
Oct 8, 2020

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Sep 23, 2020

While sendtoroute was letting you provide a custom route as a list of nodes, it made it difficult to have fine-grain control over the channels used by payments.

The API now allows choosing the exact channels that will be used for the payment; in particular, this will be helpful when consolidating and rebalancing multiple channels to a given node.

Fixes #1472

We also fix a serialization regression introduced in #1520

@t-bast t-bast requested a review from pm47 September 23, 2020 16:16
@codecov-commenter
Copy link

Codecov Report

Merging #1537 into master will decrease coverage by 0.02%.
The diff coverage is 92.00%.

@@            Coverage Diff             @@
##           master    #1537      +/-   ##
==========================================
- Coverage   87.19%   87.17%   -0.03%     
==========================================
  Files         139      139              
  Lines       10871    10882      +11     
==========================================
+ Hits         9479     9486       +7     
- Misses       1392     1396       +4     
Impacted Files Coverage Δ
...r-core/src/main/scala/fr/acinq/eclair/Eclair.scala 55.14% <0.00%> (ø)
...r/acinq/eclair/payment/send/PaymentInitiator.scala 96.51% <ø> (ø)
...r/acinq/eclair/payment/send/PaymentLifecycle.scala 93.33% <100.00%> (+0.12%) ⬆️
...cala/fr/acinq/eclair/router/RouteCalculation.scala 99.31% <100.00%> (+0.02%) ⬆️
...src/main/scala/fr/acinq/eclair/router/Router.scala 94.80% <100.00%> (+0.10%) ⬆️
...cinq/eclair/blockchain/bitcoind/zmq/ZMQActor.scala 90.00% <0.00%> (-5.00%) ⬇️
...clair/blockchain/electrum/ElectrumClientPool.scala 79.56% <0.00%> (-3.23%) ⬇️
...c/main/scala/fr/acinq/eclair/channel/Channel.scala 85.83% <0.00%> (+0.08%) ⬆️

Comment on lines +445 to +451
case class PredefinedNodeRoute(nodes: Seq[PublicKey]) extends PredefinedRoute {
override def isEmpty = nodes.isEmpty
override def targetNodeId: PublicKey = nodes.last
}
case class PredefinedChannelRoute(targetNodeId: PublicKey, channels: Seq[ShortChannelId]) extends PredefinedRoute {
override def isEmpty = channels.isEmpty
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isEmpty method seems to have a different meaning between PredefinedNodeRoute and PredefinedChannelRoute. There could be a valid empty channel route which would be a direct payment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it works the way it is, a direct payment needs one channel to be specified.

Comment on lines +247 to +260
val route = hops match {
case Left(shortChannelIds) => PredefinedChannelRoute(invoice.nodeId, shortChannelIds)
case Right(nodeIds) => PredefinedNodeRoute(nodeIds)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here there is an inconsistency that is related to my other comment. Should we define the node route as nodeIds :+ invoice.nodeId?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an inconsistency in that channel routes used the invoice's nodeId as targetNodeId, whereas in node routes we implied that the last nodeId would match the invoice's nodeId.
I added an explicit check in e802bc2 to reject node routes that are blatantly invalid.

@t-bast t-bast requested a review from pm47 October 2, 2020 07:32
While `sendtoroute` was letting you provide a custom route as a list of
nodes, it made it difficult to have fine-grain control over the channels
used by payments.

The API now allows choosing the exact channels that will be used for the
payment; in particular, this will be helpful when consolidating and
rebalancing multiple channels to a given node.

Fixes #1472
#1520 introduced a regression in the serialization of channel data,
impacted the `channels` and `channel` APIs.

We restrict the custom command response serializer to revert to the
previous behavior.
@codecov-io
Copy link

codecov-io commented Oct 8, 2020

Codecov Report

Merging #1537 into master will decrease coverage by 0.18%.
The diff coverage is 92.00%.

@@            Coverage Diff             @@
##           master    #1537      +/-   ##
==========================================
- Coverage   87.30%   87.11%   -0.19%     
==========================================
  Files         139      139              
  Lines       10896    10915      +19     
  Branches      489      451      -38     
==========================================
- Hits         9513     9509       -4     
- Misses       1383     1406      +23     
Impacted Files Coverage Δ
...r-core/src/main/scala/fr/acinq/eclair/Eclair.scala 55.14% <0.00%> (ø)
...r/acinq/eclair/payment/send/PaymentInitiator.scala 96.51% <ø> (ø)
...r/acinq/eclair/payment/send/PaymentLifecycle.scala 93.33% <100.00%> (+0.12%) ⬆️
...cala/fr/acinq/eclair/router/RouteCalculation.scala 99.31% <100.00%> (+0.02%) ⬆️
...src/main/scala/fr/acinq/eclair/router/Router.scala 94.80% <100.00%> (+0.10%) ⬆️
...clair/blockchain/electrum/ElectrumClientPool.scala 75.26% <0.00%> (-7.53%) ⬇️
...cala/fr/acinq/eclair/payment/relay/NodeRelay.scala 93.70% <0.00%> (-1.58%) ⬇️
...main/scala/fr/acinq/eclair/router/Validation.scala 91.41% <0.00%> (-1.50%) ⬇️
...nq/eclair/blockchain/electrum/ElectrumClient.scala 72.05% <0.00%> (-1.48%) ⬇️
.../eclair/payment/relay/PostRestartHtlcCleaner.scala 89.10% <0.00%> (-1.29%) ⬇️
... and 10 more

@t-bast t-bast merged commit 428349a into master Oct 8, 2020
@t-bast t-bast deleted the send-to-channel-route branch October 8, 2020 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: add an option for sendtoroute to specify channels, not just nodeID
4 participants