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 <[email protected]>
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 <[email protected]>
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Routes Scanner::decode to Lightning only on a leading lightning: scheme (now matched in any case) or a bare lnbc/lntb invoice, so a bitcoin: URI with lightning: inside label or message decodes as that URI. Reviewed 3166f06, full tier, static.
What I checked, and 5 candidates I ruled out
Read in full: src/modules/scanner/implementation.rs (decode, decode_bitcoin_uri, decode_onchain), the new tests in src/modules/scanner/tests.rs
Build/tests: build skipped: talos-pr-run could not check the author's permission on this repo (HTTP 403) and fails closed, so the 87 scanner tests in the PR body were not rerun here
CI: green, but no workflow runs modules::scanner (only paykit_route, wake, usdt and the bindgen jobs), so CI does not exercise this change
Ruled out
- Panic on the new strip:
invoice_str.get(..LIGHTNING_SCHEME.len())returnsNoneoff a char boundary, and when it returnsSomethe following byte slice starts on that same boundary. - Inputs that relied on the old
containsmatch:LIGHTNING:<BOLT11>is now stripped up front and still reachesdecode_lightningthrough thelnbc/lntbcheck, lowercased as before;bitkit://lightning:...recurses intodecode, which strips the scheme. - Leading
lightning:check after the strip: it only matches a doubledlightning:lightning:prefix; harmless, and not a behaviour change worth a fix. - Node-id
@branch catching abitcoin:URI with@in a parameter:parts[0]isbitcoin, which never contains@, and the branch is unchanged by this diff. - Uppercase
LABEL=landing inparamsinstead oflabel: pre-existing key matching indecode_onchain; the new test asserts the current behaviour.
Merge confidence: 4/5, no findings, but the scanner tests run in neither CI nor this review.
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings:
- LOW —
src/modules/scanner/tests.rs:730: Add a generated-input property test for the scheme-routing invariant; the maintained regressions use fixed examples only.
QA for 3166f06:
Native scanner tests and a review-only Swift app linked to the rebuilt library, on an iPhone 17 Pro simulator with iOS 26.5. The simulator cases call the public UniFFI decode binding directly.
Scanner regression tests ✅ All scanner regressions passed.
cargo test --locked --lib modules::scanner: 87 passed, none ignored. Formatting and diff whitespace checks also passed.
Bitcoin labels and messages containing lightning: ✅ Swift assertions preserved the on-chain result and metadata.
Checked plain and percent-encoded labels/messages, uppercase LIGHTNING: in a value, and uppercase Bitcoin QR input. Assertions checked the address, amount and retained metadata.
metadata.2x.mp4
Case-insensitive Lightning wrappers ✅ Swift assertions passed for invoices, LNURL-auth, node connections and Unicode boundaries.
Checked uppercase/mixed-case wrappers, a bitkit:// wrapper, and 39 malformed strings around UTF-8 byte boundaries. LNURL-auth decoded locally without a network request.
prefixes.2x.mp4
Bitcoin requests with Lightning fallbacks ✅ Addressless requests returned Lightning; addressed requests retained their on-chain destination and fallback.
Swift assertions checked the invoice, amount, address, label and retained lightning parameter.
fallback.2x.mp4
Not driven: consumer-app QR, paste, NFC and Bluetooth journeys, or network-backed Lightning-address lookups; this run exercised the shared decoder directly with offline inputs. Clippy was not rerun.
Full review: diff, all 3 changed files, plus the affected scanner and exported decode path. The prior static review had no runtime test evidence; the results above were run for this review.
Reviewed by gpt-6.1-sol-high
Loop over bitcoin: prefix cases, label/message/both, and values built from mixed-case lightning:, plain text, @ and : fragments, plain and percent-encoded, and check each decodes as on-chain with the same address, amount and params. Check that lightning: in any case before the same invoice decodes identically. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings: None. The new generated-input tests address the earlier LOW coverage request.
QA for 3db335d:
Check: Generated Bitcoin metadata stays on-chain ✅ Native assertions passed for 648 constructed URI inputs.
The test combines three Bitcoin scheme variants, label/message/both, and plain or percent-encoded pairs of fragments including mixed-case lightning:, spaces, @ and :. Assertions check on-chain routing, address, the 12,345-satoshi amount, label, message and retained parameter entries.
Check: Lightning prefix case variants decode identically ✅ Native assertions passed for 24 wrapper/body combinations.
Across three invoice amounts, four Lightning scheme variants and lower/uppercase invoice bodies, assertions compare BOLT11, payment hash, amount, payee and description with the decoded bare invoice.
Ran cargo test --offline --locked --lib modules::scanner::tests::tests::test_generated -- --nocapture: both tests passed, none ignored. cargo fmt --check and delta whitespace checks passed.
No new device run: this delta changes tests only. The production decoder, dependencies and exported bindings are unchanged from the passing native and Swift-binding review at 3166f06. That report's scanner regressions and simulator cases for metadata, case-insensitive wrappers and Lightning fallbacks remain applicable; they were not rerun. Consumer-app QR, paste, NFC/Bluetooth journeys and network-backed Lightning-address lookups remain outside that evidence.
Reviewed the complete 3166f06..3db335d delta: one file, two test additions and their helper, plus the scanner paths they call and the prior open coverage request. The added test code was driven by native tests; no production change required a new device case.
Reviewed by gpt-6.1-sol-high
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