Skip to content

Scanner decodes a bitcoin: URI as Lightning when a value contains lightning: #227

Todo

Description

@jvsena42

Problem

Scanner::decode sends any input whose lowercased text contains lightning: to the Lightning branch:

if invoice_str.to_lowercase().contains("lightning:")
    || invoice_str.to_lowercase().starts_with("lntb")
    ...

So a valid BIP 21/321 request with lightning: inside a parameter value fails to decode, for example bitcoin:<address>?label=pay%20lightning:x, or a message that mentions lightning:. The whole URI is parsed as a BOLT11 invoice and decoding fails. The payer never reaches the review.

This is on master (and in v0.8.0-rc15). The app hits it for every source: QR, paste, NFC and Bluetooth.

Suggested fix

Take the Lightning branch only when the request starts with lightning: (after trimming and the existing wrapper handling), or is a bare invoice (lnbc…, lntb…). A bitcoin: URI keeps going to decode_onchain, which already reads its lightning parameter. Add the case above as a scanner test.

Found by pwltr in synonymdev/bitkit-ios#1302 (review on 8e4659c).

Activity

  1. self-assigned this
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions