-
Notifications
You must be signed in to change notification settings - Fork 22
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
Offers: invoice verification #89
Conversation
2a403c9
to
4eea3dd
Compare
b6ef4a9
to
092d078
Compare
There's one unit test failure here that I'm still looking into. |
6522401
to
2bcd34b
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.
Major comment here is better handling the commits between this and the previous PR so we don't have to have double refactors. Happy for you to squash any changes you need with #85 to cut down on this 👍
src/lib.rs
Outdated
// TODO: Eventually we can use the returned payment id below to check if this | ||
// payment has been sent twice. | ||
Ok(_payment_id) => Some(OffersMessage::Invoice(invoice)), |
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.
Is it safe to leave this as a todo? Seems like this is the key thing that we need to be worried about, people sending us multiple invoices and us double-paying. Ignore me if this happens in a later on 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.
Hmm this might be worth some discussion... It seems to me like a PaymentId is only very useful when we have multiple payments in flight and need help distinguishing them. You're definitely right, we need to make sure we aren't getting double invoice requests. But for now in the lndk-cli pay-offer scenario, where there's only going to be one offer/invoice request in the OfferHandler at a time anyway, one option would be just to reject the invoice if we already updated the OfferState to InvoiceReceived, InvoicePaymentDispatched, or InvoicePaid. (I would add this to the next PR since that's where we add the invoice to a queue.) Thoughts?
Also, as you suggested, I wrote up some more context in the comments
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.
Gotcha. Can we update that todo to explain why we can leave this (for now) and still be safe?
60dc2da
to
7709037
Compare
2bcd34b
to
f439ca3
Compare
7709037
to
b51d0ac
Compare
f439ca3
to
5ac5734
Compare
bb0c078
to
d932363
Compare
48bb807
to
c9c7d63
Compare
d932363
to
d64e534
Compare
c9c7d63
to
c99be37
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.
looks good once upstream is ready
d64e534
to
b8f2d2a
Compare
5230aac
to
b221d0e
Compare
b8f2d2a
to
68ed737
Compare
b221d0e
to
6468dcf
Compare
cb6764b
to
e14f2b4
Compare
89423f4
to
c3a4f7d
Compare
e14f2b4
to
d4694ef
Compare
c3a4f7d
to
be2714c
Compare
d4694ef
to
b85cad4
Compare
Once we get an invoice returned from the offer creator, we'll be able to verify that the invoice is a response to the invoice request we sent. We can also use the PaymentId we set to verify we didn't already pay the invoice.
… method We split the unsigned invoice request (uir) signing portion into another function to make it easier to mock. Earlier we had hardcoded a signature for our lndk_offers.rs unit tests. But now that we've changed the uir being signed (by adding verification metadata), the hardcoded signature is invalid. We refactor our mocking to get rid of this hardcoded signature data completely.
be2714c
to
df53046
Compare
Verify the returned BOLT 12 invoice. Depends on #87