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

BOLT11 additional and negative tests #736

Merged
merged 5 commits into from
May 11, 2020

Conversation

rustyrussell
Copy link
Collaborator

As per last meeting, this expands the BOLT11 test vectors. I've reproduced them with the c-lightning unit tests.

rustyrussell added a commit to rustyrussell/lightning that referenced this pull request Feb 3, 2020
See-also: lightning/bolts#736
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
rustyrussell added a commit to rustyrussell/lightning that referenced this pull request Feb 3, 2020
Otherwise you can ask for a sub-millisatoshi amount, which is dumb and
violates the spec.

See-also: lightning/bolts#736
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
rustyrussell added a commit to rustyrussell/lightning that referenced this pull request Feb 3, 2020
Otherwise you can ask for a sub-millisatoshi amount, which is dumb and
violates the spec.

See-also: lightning/bolts#736
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: We now reject invoices which ask for sub-millisatoshi amounts
Copy link
Collaborator

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!
It made me realize that eclair is not currently skipping over p, h, s or n of invalid lengths but instead rejects such invoices. I'll fix that (I'm guessing it's a requirement to allow smooth upgrades of those fields right?).

11-payment-encoding.md Show resolved Hide resolved
t-bast added a commit to ACINQ/eclair that referenced this pull request Feb 4, 2020
Correctly implement skipping over hashed tags with invalid length.

See lightning/bolts#736.
cdecker pushed a commit to ElementsProject/lightning that referenced this pull request Feb 5, 2020
See-also: lightning/bolts#736
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
cdecker pushed a commit to ElementsProject/lightning that referenced this pull request Feb 5, 2020
Otherwise you can ask for a sub-millisatoshi amount, which is dumb and
violates the spec.

See-also: lightning/bolts#736
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: We now reject invoices which ask for sub-millisatoshi amounts
t-bast added a commit to ACINQ/eclair that referenced this pull request Feb 10, 2020
pm47 added a commit to ACINQ/eclair that referenced this pull request Feb 10, 2020
* Ignore fields with invalid length

As per the spec:
> A reader:
>   * MUST skip over unknown fields, OR an f field with unknown version, OR p, h, s or n fields that do NOT have data_lengths of 52, 52, 52 or 53, respectively.

* Add more Bolt 11 tests

See lightning/bolts#699
and lightning/bolts#736

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
@t-bast
Copy link
Collaborator

t-bast commented Mar 3, 2020

@cfromknecht or @Roasbeef, do we have an ACK to merge this?

Copy link
Collaborator

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM ⛰

We're going to extend the final case with negative test cases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
One for uppercase, and one with should-be-ignored fields.

The first of these addresses lightning#659 (lightning#677 directly changes the text
to make it clear this is allowed, and should also be applied).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This tests various forms of malformed invoices (it's not exhaustive though).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We added a requirement on the writer, not the reader.  We can't really add
a test vector without a new requirement, though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…trings.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell
Copy link
Collaborator Author

OK, rebased: had to hoist the new pico-btc test higher, so we could put the new variants underneath the existing ones.

@rustyrussell rustyrussell merged commit 5322c2b into lightning:master May 11, 2020
@rustyrussell
Copy link
Collaborator Author

kafaichoi added a commit to RiverFinancial/bitcoinex that referenced this pull request May 16, 2020
return error tuple instead of crashing when decoding a ln invoice with
sub msat in amount

new test vectors are copied from lightning/bolts#736
mononaut pushed a commit to bitfeed-project/bitfeed that referenced this pull request Dec 2, 2021
return error tuple instead of crashing when decoding a ln invoice with
sub msat in amount

new test vectors are copied from lightning/bolts#736
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.

3 participants