-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
invoices: add subscribesingleinvoice #2356
invoices: add subscribesingleinvoice #2356
Conversation
ff5e889
to
6225ced
Compare
6154c5e
to
6fe9e32
Compare
3340c88
to
3eedbcf
Compare
44baf90
to
dedf7fe
Compare
lnrpc/invoicesrpc/invoices_server.go
Outdated
|
||
// Now that we know the full path of the invoices macaroon, we can | ||
// check to see if we need to create it or not. | ||
if !fileExists(macFilePath) && cfg.MacService != nil { |
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.
preferably this logic would also be made into a helper method in lnrpc
as well. would you be opposed to doing so and then we can defer a refactoring of other subservers to a later PR?
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.
Gave it a try, but it gets many parameters. I think it may be better to, in a separate pr, have subservers expose some macaroon info and bake the macaroon somewhere else.
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.
sounds good, thanks!
522ad59
to
970984a
Compare
@cfromknecht PTAL |
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.
Thanks @joostjager, few last nits. Otherwise i'd say this about ready to land! 🎉
// | ||
// NOTE: This is part of the lnrpc.SubServer interface. | ||
func (s *Server) Stop() error { | ||
close(s.quit) |
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 think it'd be worth protecting this with a compare and swap to prevent us from accidentally closing the same channel twice, as it would lead us to panic during shutdown. Start should be fine though since it's a NOP
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.
Calling Stop()
twice is invalid use of the subserver and adding the compare/swap would camouflage this. We would loose the opportunity to discover the bug of the caller. In general I'd like to avoid defensive code, unless we are dealing with legacy that has become too complicate to reason about and we want to take no risk.
970984a
to
07b561e
Compare
df424fe
to
0e291b2
Compare
Leaktest removed. CLI command removed. |
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.
Needs a go mod tidy
, but other than that, LGTM 🐣
0e291b2
to
5c73328
Compare
Stale review dismissed, ptal |
0f2ab5b
to
b640b48
Compare
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 🌶
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 📈
This commit adds new hash and preimage types. These types are similar to chainhash.Hash, except for that string representations are not reversed. The reason for adding dedicated types and not use [32]byte, is to facilitate logging (%v displays as hex string) and have standard methods to convert from byte slice and string with a length check.
Previously chainhash.Hash was used, which converts to/from string in reversed format. Payment hashes and preimages are supposed to be non-reversed.
Sub server implementation is still empty. This is a preparatory step for adding invoice functionality.
Needs a rebase! |
Without this addition, sub servers cannot import google annotations in their proto files.
As a preparation for subscribing to single invoices, InvoiceRegistry needs to become aware of settling a settled invoice.
As a preparation for reusing the marshall code in the invoices sub server.
b640b48
to
c049173
Compare
c049173
to
b163571
Compare
@halseth @cfromknecht @Roasbeef Rebased, ptal |
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 🥘
This PR allows listening to a notification stream for a single invoice.
Usage
SubscribeSingleInvoice
is only available for applications integrating directly with thelnd
invoices sub server grpc interface. It is not accessible throughlncli
.After registering for single invoice notifications, the caller will immediately receive the current invoice state via the stream. From there onwards,
lnd
will continue pushing updates as they happen.If the invoice that is subscribed to doesn't exist yet, the call will still block and start streaming when the invoice is created.
Build
Requires
lnd
to be built with theinvoicesrpc
build tag:make tags="invoicesrpc"