-
Notifications
You must be signed in to change notification settings - Fork 123
lndclient: extend LightningClient with ListChannels and RouterClient with keysend #203
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
Conversation
5b9b6be to
e8ff2d0
Compare
lndclient/lightning_client.go
Outdated
|
|
||
| // ListChannels retrieves all channels of the backing lnd node. | ||
| func (s *lightningClient) ListChannels(ctx context.Context) ( | ||
| []*lnrpc.Channel, error) { |
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.
The idea of the wrapper is to not expose things like string based pubkeys. Ideally we'd create a strongly-typed struct to return a slice of. Can for now just contains the fields that we need.
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.
done
lndclient/router_client.go
Outdated
| // to complete the full amount. | ||
| MaxParts uint32 | ||
|
|
||
| // KeySend is set to true if the payment request will encode the preimage. |
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.
payment request generally refers to the hex-encoded invoice. You probably mean the tlv payload?
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.
ptal
lndclient/router_client.go
Outdated
| // Override the payment hash. | ||
| rpcReq.DestCustomRecords = make(map[uint64][]byte) | ||
| rpcReq.DestCustomRecords[record.KeySendType] = preimage[:] | ||
| request.PaymentHash = preimage.Hash() |
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.
Assert that PaymentHash wasn't set, to catch unintended use?
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.
done
e8ff2d0 to
f9a8c72
Compare
|
|
||
| result := make([]ChannelInfo, len(response.Channels)) | ||
| for i, channel := range response.Channels { | ||
| remoteVertex, err := route.NewVertexFromStr(channel.RemotePubkey) |
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.
Future devs will thank you for the luxury of not having to parse everywhere :)
lndclient/lightning_client.go
Outdated
| PubKeyBytes route.Vertex | ||
|
|
||
| // Capacity is the total amount of funds held in this channel. | ||
| Capacity int64 |
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.
Can be type btcutil.Amount, just as the balances below
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.
indeed, that is much better
lndclient/router_client.go
Outdated
| rpcReq.LastHopPubkey = request.LastHopPubkey[:] | ||
| } | ||
| if request.KeySend { | ||
| if !bytes.Equal(request.PaymentHash[:], emptyHash[:]) { |
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.
If payment hash is optional, it would be better to make it type *lntypes.Hash to avoid the magic value.
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.
agree, much nicer to have the *lntypes.Hash, done
de0c509 to
78c358c
Compare
78c358c to
1515c92
Compare
lndclient/router_client.go
Outdated
|
|
||
| // Override the payment hash. | ||
| rpcReq.DestCustomRecords = make(map[uint64][]byte) | ||
| rpcReq.DestCustomRecords[record.KeySendType] = preimage[:] |
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.
Alternative. Fewer characters but more lines :) Non-blocking ofc
rpcReq.DestCustomRecords = map[uint64][]byte {
record.KeySendType: preimage[:],
}
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.
done, probably compiles to the same code, but more readable :)
1515c92 to
fee150c
Compare
carlaKC
left a comment
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.
LGTM!
| ListTransactions(ctx context.Context) ([]*wire.MsgTx, error) | ||
|
|
||
| // ListChannels retrieves all channels of the backing lnd node. | ||
| ListChannels(ctx context.Context) ([]ChannelInfo, error) |
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.
[]*ChannelInfo?
fee150c to
620365b
Compare
620365b to
cf9c374
Compare
This PR adds
ListChannelstoLightningClientand extendsRouterClient.SendPaymentwith keysend.