-
Notifications
You must be signed in to change notification settings - Fork 406
Fix and modernize lightning-invoice API #1057
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
Conversation
6d3321f
to
669b3ea
Compare
This swaps out our doctest example invoices for real LDK-generated invoices on a real LDK node.
669b3ea
to
f631178
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
618d801
to
11f0698
Compare
Updated but note still failing one last test case that I think t-bast will update cc lightning/bolts#898 (comment) |
11f0698
to
3e1b78b
Compare
Updated again now that the last error is fixed, should be good to go! |
3e1b78b
to
a5c5848
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
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.
a5c5848
to
6879348
Compare
Squashed without changes, will take after CI:
|
Fixes lightningdevkit/ldk-garbagecollected#41 and requires payment_secrets