Repository navigation
Conversation
Scanner::decode sent any input containing `lightning:` to the Lightning decoder, so a bitcoin: URI with `lightning:` in a label or message failed to decode. Match the scheme at the start only. Fixes #227 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The leading `lightning:` strip was case-sensitive, so `LIGHTNING:` with an LNURL, node id or Lightning address reached the BOLT11 decoder and failed. Also test an uppercase bitcoin: URI with `LIGHTNING:` in its label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #227
Cause
Scanner::decodetook the Lightning branch when the lowercased input containedlightning:. Abitcoin:URI withlightning:inside a parameter value, such asbitcoin:<address>?label=pay%20lightning:xor the same inmessage, went todecode_lightningand failed withInvalidFormat.The leading
lightning:strip at the top ofdecodewas also case-sensitive.LIGHTNING:followed by an LNURL, a node id (pubkey@host:port) or a Lightning address skipped that strip, matched thecontainscheck, and failed in the BOLT11 decoder.Change
lightning:strip andbitkit://handling) starts withlightning:in any case, or is a barelnbc/lntbinvoice (lnbcrtandlntbsare covered by those prefixes). Abitcoin:URI goes todecode_bitcoin_uri, which already reads itslightningparameter.lightning:strip is now case-insensitive, the same waydecode_onchainstripsbitcoin:.LIGHTNING:LNURL1…,LIGHTNING:<pubkey>@host:portandLIGHTNING:user@domainnow reach the LNURL, node-id and Lightning address paths.LIGHTNING:<BOLT11>decodes as before.contains(...)calls indecode. The node-id@check only fires when the part before the single:contains@, so abitcoin:URI never matches;contains("onion")only runs inside that branch. Neither has the bug.Known, pre-existing, out of scope
lnsb) are not recognised as bare invoices.lightning://(with slashes) is not stripped.lno…) are not decoded.Tests
New scanner tests:
lightning:(percent-encoded, plain, uppercase)lightning:(percent-encoded and plain)BITCOIN:<ADDR>?LABEL=LIGHTNING:Xdecodes as on-chainLIGHTNING:prefix with a lowercase invoice still decodes as LightningLIGHTNING:LNURL1…andLightning:lnurl1…(LNURL-auth, no network request) decode asLnurlAuthLIGHTNING:<pubkey>@host:portdecodes asNodeIdbitcoin:?lightning=<bolt11>still decodes as Lightningbitcoin:<address>?...&lightning=<bolt11>decodes as on-chain with the invoice inparamsRun locally (CI does not run
modules::scanner):cargo test --locked --lib modules::scanner: 87 passed, 0 failed.implementation.rs: master fails 6 (label, message, address pluslightning, uppercase QR label, uppercase LNURL, uppercase node id); 53e5b18 fails 2 (uppercase LNURL, uppercase node id).cargo fmt --check: clean.cargo clippy --locked --lib --tests: same warning set as before this change (compared with the previous head, 53e5b18, which added none over master).🤖 Generated with Claude Code