Skip to content

Add BOLT11DecodeException and InvalidBitcoinURI wraps for missing uncaught exceptions. - #10940

Merged
f321x merged 9 commits into
spesmilo:masterfrom
accumulator:fix_10937
Sep 14, 2026
Merged

f321x merged 9 commits into
spesmilo:masterfrom
accumulator:fix_10937

Conversation

@accumulator

@accumulator accumulator commented Sep 7, 2026

Copy link
Copy Markdown
Member

add BOLT11DecodeException and InvalidBitcoinURI wraps for missing uncaught exceptions.

fixes #10937

Also this implements tightened rules as described in lightning/bolts#1243

  • MUST include exactly one p field
  • MUST include exactly one s field
  • MUST include either exactly one d or exactly one h field

Note: this makes bolt11 decoding more strict, therefore a wallet_db migration has been added to remove invoices not passing the strict parse.

Note2: this rabbit-holed a lot more than just fixing 10937, validation brought up to spec with https://github.com/lightning/bolts/blob/master/11-payment-encoding.md#tagged-fields

@accumulator
accumulator force-pushed the fix_10937 branch 6 times, most recently from 3883bdb to 4f072e0 Compare September 7, 2026 14:50
@accumulator
accumulator marked this pull request as ready for review September 7, 2026 15:12
Comment thread electrum/bolt11.py Outdated
Comment thread electrum/bolt11.py Outdated
Comment thread electrum/bolt11.py
Comment thread electrum/bolt11.py
@accumulator
accumulator marked this pull request as draft September 11, 2026 08:22
@accumulator
accumulator force-pushed the fix_10937 branch 5 times, most recently from c41543d to cf03b44 Compare September 11, 2026 11:38
…as BOLT11DecodeException

also make fallback address parsing more strict.

This implements tightened rules as described in lightning/bolts#1243
- MUST include exactly one p field
- MUST include exactly one s field
- MUST include either exactly one d or exactly one h field
route data/amount constructor arguments through setters, so we don't skip validation
We implement exactly the DB upgrade the comment there describes,
so the old tests can be removed.
replaces invoices in tests with invoices with payment secret
replaces lnpeer transitive feature test from BASIC_MPP_OPT -> PAYMENT_SECRET_OPT to
PAYMENT_SECRET_OPT -> VAR_ONION_OPT
@accumulator
accumulator marked this pull request as ready for review September 11, 2026 12:28
@ecdsa ecdsa changed the title Fix 10937 Add BOLT11DecodeException and InvalidBitcoinURI wraps for missing uncaught exceptions. Sep 11, 2026
Comment thread electrum/bolt11.py Outdated
Comment thread tests/test_bolt11.py
Comment thread electrum/bolt11.py Outdated
Comment thread electrum/bolt11.py Outdated
Comment thread electrum/bolt11.py
Address review comments of spesmilo#10940
@f321x
f321x merged commit a57ef6e into spesmilo:master Sep 14, 2026
11 checks passed
@SomberNight

SomberNight commented Sep 18, 2026

Copy link
Copy Markdown
Member

Were you already looking at lightning/bolts#1357 too, or is it a coincidence that you also fixed that here?

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.

Unhandled exception in parse_bip21_URI for crafted lightning parameter in bitcoin: URI

3 participants