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

Fix and modernize lightning-invoice API #1057

Merged
merged 9 commits into from Aug 31, 2021

Conversation

TheBlueMatt
Copy link
Collaborator

Fixes lightningdevkit/ldk-garbagecollected#41 and requires payment_secrets

This swaps out our doctest example invoices for real LDK-generated
invoices on a real LDK node.
@codecov
Copy link

codecov bot commented Aug 22, 2021

Codecov Report

Merging #1057 (a5c5848) into main (2ced708) will increase coverage by 0.84%.
The diff coverage is 87.71%.

❗ Current head a5c5848 differs from pull request most recent head 6879348. Consider uploading reports for the commit 6879348 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1057      +/-   ##
==========================================
+ Coverage   90.82%   91.66%   +0.84%     
==========================================
  Files          65       65              
  Lines       32801    36884    +4083     
==========================================
+ Hits        29791    33811    +4020     
- Misses       3010     3073      +63     
Impacted Files Coverage Δ
lightning-invoice/src/de.rs 80.73% <0.00%> (ø)
lightning-invoice/src/lib.rs 88.11% <89.36%> (-0.39%) ⬇️
lightning-invoice/src/utils.rs 84.26% <100.00%> (ø)
lightning/src/ln/features.rs 99.43% <100.00%> (ø)
lightning/src/routing/network_graph.rs 91.81% <100.00%> (ø)
lightning/src/routing/router.rs 95.94% <100.00%> (ø)
lightning/src/util/enforcing_trait_impls.rs 89.54% <0.00%> (-0.85%) ⬇️
lightning-background-processor/src/lib.rs 94.85% <0.00%> (+0.91%) ⬆️
lightning/src/chain/keysinterface.rs 96.32% <0.00%> (+0.95%) ⬆️
lightning/src/ln/functional_tests.rs 98.86% <0.00%> (+1.38%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ced708...6879348. Read the comment docs.

@TheBlueMatt TheBlueMatt added this to the 0.0.101 milestone Aug 23, 2021
@TheBlueMatt TheBlueMatt force-pushed the 2021-08-invoice-fails branch 2 times, most recently from 618d801 to 11f0698 Compare August 27, 2021 02:21
@TheBlueMatt
Copy link
Collaborator Author

Updated but note still failing one last test case that I think t-bast will update cc lightning/bolts#898 (comment)

@TheBlueMatt
Copy link
Collaborator Author

Updated again now that the last error is fixed, should be good to go!

lightning-invoice/tests/ser_de.rs Outdated Show resolved Hide resolved
lightning-invoice/src/lib.rs Outdated Show resolved Hide resolved
lightning-invoice/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

LGTM

This adds two additional tests from the BOLT 11 invalid invoice
tests, fixing the two errors that broke them. It fixes a panic on
the "nonrecoverable signature" test and makes the error variant
more sensible on the bogus SI prefix test.
The BOLT 11 invalid invoice test vectors suggest failing to parse
invoices which have an amount which is not a whole number of
millisatoshis. lightning-invoice, however, happily parses such
invoices. While we could continue to parse them, failing them makes
for one less check on the user code side, so we might as well.

In order to keep the invoice creation less likely to fail, we also
switch the Builder amount-setting function to use millisatoshis.
This adds the final missing BOLT 11 failure test, checking for
unknown required feature flags before accepting an invoice.
BOLT 11 states that a reader "MUST skip over...`p`, `h`, `s` or `n`
fields that do NOT have data_lengths of 52, 52, 52 or 53,
respectively." Here we do so by simply ignoring any invalid-length
field.
This pulls the BOLT 11 test vectors from
lightning/bolts#898,
tweaking our tests to properly handle them.
@TheBlueMatt
Copy link
Collaborator Author

Squashed without changes, will take after CI:

$ git diff-tree -U1 a5c58482 68793485
$

@TheBlueMatt TheBlueMatt merged commit 6bd1af4 into lightningdevkit:main Aug 31, 2021
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.

Invalid invoice parsing issues
4 participants