Skip to content

bolt12: Add test vector for missing offer_amount with offer_currency#1279

Merged
t-bast merged 1 commit intolightning:masterfrom
erickcestari:add-offer-test-vector
Jan 5, 2026
Merged

bolt12: Add test vector for missing offer_amount with offer_currency#1279
t-bast merged 1 commit intolightning:masterfrom
erickcestari:add-offer-test-vector

Conversation

@erickcestari
Copy link
Copy Markdown
Contributor

During differential fuzzing between C-lightning and rust-lightning, discovered that C-lightning incorrectly accepts offers with offer_currency set but offer_amount missing, while rust-lightning rejects them.

The BOLT 12 specification states in "Requirements For Offers":

if offer_currency is set and offer_amount is not set:

  • MUST NOT respond to the offer.

This pr adds a test vector for the invalid offer:
lno1qcp4256ypgx9getnwss8vetrw3hhyuckyypwa3eyt44h6txtxquqh7lz5djge4afgfjn7k4rgrkuag0jsd5xvxg

Which contains CURRENCY=USD but no amount field, and should be rejected by all compliant implementations.

I got this test vector from:
https://github.com/ElementsProject/lightning/blob/c3362b057c2174589024254f4cab9eb8d955a26f/common/test/run-bolt12-encode-test.c#L439

Adds a test case to verify that offers with offer_currency set but
offer_amount missing are correctly rejected, as required by BOLT 12
specification section "Requirements For Offers":

"if `offer_currency` is set and `offer_amount` is not set:
 - MUST NOT respond to the offer."
@thomash-acinq
Copy link
Copy Markdown

Thanks.
Eclair too fails this test, I've fixed it in ACINQ/eclair#3140.

Copy link
Copy Markdown
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.

ACK 96938ce

thomash-acinq added a commit to ACINQ/eclair that referenced this pull request Aug 19, 2025
@t-bast
Copy link
Copy Markdown
Collaborator

t-bast commented Sep 17, 2025

@rustyrussell could you fix this on the cln side and verify this test vector?

Copy link
Copy Markdown
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

ACK 96938ce

Copy link
Copy Markdown
Contributor

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

ACK

@t-bast
Copy link
Copy Markdown
Collaborator

t-bast commented Dec 19, 2025

I think this PR is ready to go, but since it found a bug in cln, we need to make sure that cln now supports this: @madelinevibes could you check whether this is the case?

@madelinevibes
Copy link
Copy Markdown

I think this PR is ready to go, but since it found a bug in cln, we need to make sure that cln now supports this: @madelinevibes could you check whether this is the case?

Rusty is taking some well deserved PTO but this is definitely on the list for 5 Jan! Thanks for your patience @t-bast

rustyrussell added a commit to rustyrussell/lightning that referenced this pull request Jan 4, 2026
Should fail: see lightning/bolts#1279

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

Fixed, and ack 96938ce

Thanks!

@t-bast t-bast merged commit 1560eac into lightning:master Jan 5, 2026
rustyrussell added a commit to rustyrussell/lightning that referenced this pull request Jan 30, 2026
Should fail: see lightning/bolts#1279

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
rustyrussell added a commit to ElementsProject/lightning that referenced this pull request Feb 3, 2026
Should fail: see lightning/bolts#1279

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
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.

8 participants