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

Introduce Reply Paths for BOLT12 Invoice in Offers Flow. #3163

Merged
merged 5 commits into from
Sep 11, 2024

Conversation

shaavan
Copy link
Contributor

@shaavan shaavan commented Jul 9, 2024

This PR builds on #3087 and addresses this comment.

Changes:

  1. Updates the Offers message flow to include reply_path with the sent BOLT12Invoice.
  2. Ensures that in case of an error, the counterparty can send back any InvoiceError along the reply_path.
  3. Updates the Offers test to check for the invoice's reply_path wherever applicable.

@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2024

Codecov Report

Attention: Patch coverage is 77.04918% with 14 lines in your changes missing coverage. Please review.

Project coverage is 90.39%. Comparing base (5e62df7) to head (7b49993).
Report is 62 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 66.66% 9 Missing ⚠️
lightning/src/offers/signer.rs 68.75% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3163      +/-   ##
==========================================
+ Coverage   89.82%   90.39%   +0.57%     
==========================================
  Files         126      126              
  Lines      103024   108017    +4993     
  Branches   103024   108017    +4993     
==========================================
+ Hits        92543    97644    +5101     
- Misses       7769     7815      +46     
+ Partials     2712     2558     -154     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jkczyz jkczyz self-requested a review July 9, 2024 14:54
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
lightning/src/ln/offers_tests.rs Outdated Show resolved Hide resolved
@TheBlueMatt
Copy link
Collaborator

Needs rebase now.

@shaavan
Copy link
Contributor Author

shaavan commented Jul 17, 2024

Updated from pr3163.01 to pr3163.02 (diff):
Addressed @jkczyz and @TheBlueMatt comments

Changes:

  1. Rebase on main.
  2. Introduce a fixup commit to introduce context in respond_with_reply_path.

@TheBlueMatt
Copy link
Collaborator

Please include details about what you're doing and why in the commit messages.

@jkczyz
Copy link
Contributor

jkczyz commented Jul 17, 2024

Please include details about what you're doing and why in the commit messages.

Sorry about being lax when reviewing this. @shaavan I recommend this reference, which we mention in the project contributor guidelines: https://cbea.ms/git-commit/

@TheBlueMatt
Copy link
Collaborator

I'm usually pretty lax as long as its clear from the code what's going on, but in this case I look at the commit and we're just adding a blinded path, which doesn't tell me anything about why. I have some context from a separate commit in a different PR, but I don't want to rely on that :)

@shaavan
Copy link
Contributor Author

shaavan commented Jul 18, 2024

Updated from pr3163.02 to pr3163.03 (diff):
Addressed @TheBlueMatt and @jkczyz comments

Changes:

  1. Squashed the commits
  2. Update the Commit description to be clearly detailed.

Thanks, @TheBlueMatt for the suggestion, and @jkczyz for the resource!

@@ -10620,7 +10620,10 @@ where
};

match response {
Ok(invoice) => responder.respond(OffersMessage::Invoice(invoice)),
Ok(invoice) => {
let context = MessageContext::Offers(OffersContext::Unknown {});
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are we actually gonna do with the InvoiceError now? This is for an inbound payment, presumably we'll just log and move on? Do we want to authenticate the BP at all? @jkczyz

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I'd figure we'd just log. What is "BP" refer to here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, blinded path. 😛 We could though maybe a lower log level is fine for now. Not sure how much we can do about sending another invoice without another request.

@shaavan
Copy link
Contributor Author

shaavan commented Aug 20, 2024

Updated from pr3163.03 to pr3163.04 (diff):

Changes:

  1. Rebase on main, to resolve merge conflicts.

@shaavan
Copy link
Contributor Author

shaavan commented Aug 21, 2024

Updated from pr3163.04 to pr3163.05 (diff):

Changes:

  1. Moved the relevant change to the relevant commit to have a clean commit history.

@shaavan
Copy link
Contributor Author

shaavan commented Aug 28, 2024

Updated from pr3163.05 to pr3163.06 (diff):

Changes:

  1. Rebase on main.

@shaavan
Copy link
Contributor Author

shaavan commented Aug 28, 2024

Updated from pr3163.06 to pr3163.07 (diff):
Addressed @jkczyz comment

  1. Update the check in a test to maintain channel setup consistency with the other tests.

@shaavan
Copy link
Contributor Author

shaavan commented Aug 29, 2024

Updated from pr3163.07 to pr3163.08 (diff):
Addressed @jkczyz comment

  1. Remove an extra redundant node introduced earlier in the test.

jkczyz
jkczyz previously approved these changes Aug 30, 2024
When a InvoiceError is received for a sent BOLT12Invoice, the
corresponding PaymentHash is to be logged. Introduce hmac construction
and verification function for PaymentHash for this purpose.
@shaavan
Copy link
Contributor Author

shaavan commented Sep 6, 2024

Updated from pr3163.08 to pr3163.09 (diff):
Addressed @TheBlueMatt comment

Changes:

  1. Introduce HMAC calculation and verification for OffersContext::InboundPayment.

lightning/src/blinded_path/message.rs Outdated Show resolved Hide resolved
lightning/src/blinded_path/message.rs Outdated Show resolved Hide resolved
lightning/src/blinded_path/message.rs Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
@shaavan
Copy link
Contributor Author

shaavan commented Sep 9, 2024

Updated from pr3163.09 to pr3163.10 (diff):
Addressed @jkczyz comments

Changes:

  1. Update docs.
  2. Always use new nonce for the reply path sent with Bolt12Invoice.

- The trait defines the public method one may define for creating and
  verifying the HMAC.
- Using a pub trait to define these method allows the flexibility for
  other `OffersMessageHandler` construct to construct the HMAC and
authenticate the message.
@shaavan
Copy link
Contributor Author

shaavan commented Sep 10, 2024

Updated from pr3163.10 to pr3163.11 (diff):
Addressed @jkczyz comment

Changes:

  1. Introduce Verification trait that define the public function required for creating and verifying HMAC.
  2. Define the trait impl for PaymentId, and PaymentHash.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

LGTM, feel free to squash.

Introduce HMAC and nonce calculation when sending Invoice with
reply path, so that if we receive InvoiceError back for the
corresponding Invoice we can verify the payment hash before logging it.
1. Introduced reply_path in BOLT12Invoices to address a gap in error handling.
   Previously, if a BOLT12Invoice sent in the offers flow generated an Invoice Error,
   the payer had no way to send this error back to the payee.
2. By adding a reply_path to the Invoice Message, the payer can now communicate
   any errors back to the payee, ensuring better error handling and communication
   within the offers flow.
1. Updated the Offers Test to check the reply paths in BOLT12 Invoices.
2. Changed the `extract_invoice` return type from `Option<BlindedMessagePath>`
   to `BlindedMessagePath` since all BOLT12Invoices now have a corresponding
   reply path by default.
@shaavan
Copy link
Contributor Author

shaavan commented Sep 11, 2024

Updated from pr3163.11 to pr3163.12 (diff):
Addressed @TheBlueMatt comment

Changes:

  1. Squash fixups.

@TheBlueMatt TheBlueMatt merged commit 4178dd7 into lightningdevkit:main Sep 11, 2024
16 of 19 checks passed
@shaavan shaavan deleted the invoice_reply_path branch September 12, 2024 12:56
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.

4 participants