Skip to content

lnrpc: allow pubkey in SendToRoute#1944

Merged
Roasbeef merged 2 commits into
lightningnetwork:masterfrom
joostjager:sendroute-pubkey
Nov 5, 2018
Merged

lnrpc: allow pubkey in SendToRoute#1944
Roasbeef merged 2 commits into
lightningnetwork:masterfrom
joostjager:sendroute-pubkey

Conversation

@joostjager
Copy link
Copy Markdown
Contributor

@joostjager joostjager commented Sep 20, 2018

The information in the Route RPC message is not enough to directly send out the payment. First the local channel graph needs to be queried to complete the data. A lookup is executed to retrieve the public key of a node based on channel id. This does not work with private channels.

In this PR, we allow the hop pubkeys to be passed in so that execution of the payment becomes independent of the channel graph.

It is also a step towards the unbundling of lnd. (maybe, in the future, we get a node that doesn't track the channel graph at all anymore and is just a payment executor. mobile maybe?)

Fixes #2139.

@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour routing P4 low prio rpc Related to the RPC interface labels Sep 21, 2018
@joostjager joostjager changed the title lnrpc: allow pubkey in SendToRoute [DO NOT REVIEW] lnrpc: allow pubkey in SendToRoute Oct 24, 2018
@halseth halseth added this to the 0.5.2 milestone Oct 24, 2018
@Roasbeef Roasbeef requested a review from wpaulino October 26, 2018 21:14
Copy link
Copy Markdown
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

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

Cool change! We should add a godoc to each of the existing and new methods.

@joostjager
Copy link
Copy Markdown
Contributor Author

godoc added

Comment thread rpcserver.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Regarding commit structure: it looks like this change (extracting logic into unmarshallHopByChannelLookup) could be done in an individual commit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Commit added

Comment thread rpcserver.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I would prefer this check be done inside the unmarshal method. Shouldn't be a problem passing in the graph even though it might not be needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My goal was to have a version of unmarshall that does not have that dependency. I refactored it into a form that satisfies both our requirements.

Comment thread rpcserver.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this comment belongs by the definition of the PubKey field.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved

@joostjager
Copy link
Copy Markdown
Contributor Author

Comments processed

Comment thread rpcserver.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm, strange wrapping?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought so too, but this is what gofmt does.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe this works?

PubKey: hex.EncodeToString(
                hop.PubKeyBytes[:],
        ),
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No

Comment thread rpcserver.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

prevNodePubKey should be made [33]byte

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why? This way there is less byte copying.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It makes the length clear, and makes sure it is non-nil. I don't think any extra byte copying makes a difference in this case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed. Not sure it was worth it. It is a minor thing which to me is also a matter of preference.

By passing a pubkey into SendToRoute, it becomes unnecessary for lnd to
query the channel graph to retrieve the hop pubkey. This allows routes
over private channels that are not present in the graph.
Copy link
Copy Markdown
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

LGTM 🏁

Copy link
Copy Markdown
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🧶

@Roasbeef Roasbeef merged commit c0fadcc into lightningnetwork:master Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvements to existing features / behaviour P4 low prio routing rpc Related to the RPC interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants