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

Open
wants to merge 4 commits into
base: master
from

Conversation

@rustyrussell
Copy link
Collaborator

rustyrussell commented Feb 2, 2020

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

rustyrussell added 4 commits Feb 2, 2020
One for uppercase, and one with should-be-ignored fields.

The first of these addresses #659 (#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 added a commit to rustyrussell/lightning that referenced this pull request Feb 3, 2020
See-also: lightningnetwork/lightning-rfc#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: lightningnetwork/lightning-rfc#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: lightningnetwork/lightning-rfc#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 left a comment

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?).

> ### Invalid multiplier
> lnbc2500x1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpujr6jxr9gq9pv6g46y7d20jfkegkg4gljz2ea2a3m9lmvvr95tq2s0kvu70u3axgelz3kyvtp2ywwt0y8hkx2869zq5dll9nelr83zzqqpgl2zg
> ### Invalid sub-millisatoshi precision.

This comment has been minimized.

Copy link
@t-bast

t-bast Feb 3, 2020

Collaborator

Just a small clarification on that one: IIUC there's no requirement on the reader in the spec.
So it's ok if a reader just rounds this down to millisatoshi without rejecting the payment?
Or should we make the spec stricter on readers in that case?

This comment has been minimized.

Copy link
@rustyrussell

rustyrussell Feb 17, 2020

Author Collaborator

Good q, I was undecided. I would think reader would have to round up, but it's probably best to just reject as nonsensical.

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 lightningnetwork/lightning-rfc#736.
cdecker added a commit to ElementsProject/lightning that referenced this pull request Feb 5, 2020
See-also: lightningnetwork/lightning-rfc#736
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
cdecker added 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: lightningnetwork/lightning-rfc#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 lightningnetwork/lightning-rfc#699
and lightningnetwork/lightning-rfc#736

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.