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

BOLT 12 spec updates #1972

Merged
merged 4 commits into from
Jan 30, 2023

Conversation

jkczyz
Copy link
Contributor

@jkczyz jkczyz commented Jan 19, 2023

A few changes / clarifications to the BOLT 12 spec (lightning/bolts#798) were made after some recent discussions:

  • allow offer_quantity_max = 1
  • allow invreq_quantity in refunds
  • disallow offer_metadata in refunds

This PR updates the offers module to reflect these. Based on #1926.

@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2023

Codecov Report

Base: 91.39% // Head: 91.66% // Increases project coverage by +0.27% 🎉

Coverage data is based on head (61c9fcb) compared to base (15f1295).
Patch coverage: 97.50% of modified lines in pull request are covered.

❗ Current head 61c9fcb differs from pull request most recent head 22ea505. Consider uploading reports for the commit 22ea505 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1972      +/-   ##
==========================================
+ Coverage   91.39%   91.66%   +0.27%     
==========================================
  Files          98       98              
  Lines       57080    58640    +1560     
  Branches    57080    58640    +1560     
==========================================
+ Hits        52167    53755    +1588     
+ Misses       4913     4885      -28     
Impacted Files Coverage Δ
lightning/src/offers/invoice.rs 94.79% <ø> (ø)
lightning/src/offers/parse.rs 94.00% <ø> (ø)
lightning/src/offers/offer.rs 92.99% <91.66%> (-0.34%) ⬇️
lightning/src/offers/invoice_request.rs 96.24% <100.00%> (+0.11%) ⬆️
lightning/src/offers/refund.rs 96.04% <100.00%> (+0.15%) ⬆️
lightning/src/chain/onchaintx.rs 94.35% <0.00%> (-0.84%) ⬇️
lightning/src/ln/inbound_payment.rs 92.69% <0.00%> (-0.81%) ⬇️
lightning/src/chain/keysinterface.rs 86.25% <0.00%> (-0.71%) ⬇️
lightning-net-tokio/src/lib.rs 85.80% <0.00%> (-0.21%) ⬇️
lightning/src/ln/functional_tests.rs 96.97% <0.00%> (-0.03%) ⬇️
... and 9 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@valentinewallace
Copy link
Contributor

Needs rebase

@jkczyz jkczyz force-pushed the 2023-01-bolt12-spec-updates branch 2 times, most recently from 6459cb8 to 61c9fcb Compare January 25, 2023 15:57
TheBlueMatt
TheBlueMatt previously approved these changes Jan 26, 2023
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.

Didn't bother checking the BOLTs, but code looks good.

lightning/src/offers/invoice_request.rs Show resolved Hide resolved
@@ -552,22 +550,20 @@ pub enum Quantity {
/// Up to a specific number of items (inclusive).
Bounded(NonZeroU64),
/// One or more items.
///
/// May be used with `NonZeroU64::new(1)` but prefer to use [`Quantity::One`] if only one item
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you added this comment on the wrong variant. More generally, I'd expect this to tell me why I should use one or the other, not just that I should.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Fixed and further documented each variant. PTAL

The spec was modified to allow setting offer_quantity_max explicitly to
one. This is to support a use case where more than one item is supported
but only one item is left in the inventory. Introduce a Quantity::One
variant to replace Quantity::Bounded(1) so the later can be used for the
explicit setting.
The spec always allowed this but the reason was unclear. It's useful if
the refund is for an invoice paid for offer where a quantity was given
in the request. The description in the refund would be from the offer,
which may have given a unit for each item. So allowing a quantity makes
it clear how many items the refund is for.
The offer_metadata was optional but is redundant with invreq_metadata
(i.e., payer_metadata) for refunds. It is now disallowed in the spec and
was already unsupported by RefundBuilder.
@jkczyz jkczyz force-pushed the 2023-01-bolt12-spec-updates branch from 5d6469f to 22ea505 Compare January 30, 2023 21:44
@TheBlueMatt TheBlueMatt merged commit ccf9215 into lightningdevkit:main Jan 30, 2023
@jkczyz jkczyz mentioned this pull request May 10, 2023
60 tasks
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