sbddesign / bip21-site

A website for tracking community support for BIP21 QR codes that support on-chain and lightning bitcoin payments.
https://bitcoinqr.dev
MIT License
30 stars 24 forks source link

Why the scheme is not uppercased? #86

Closed RCasatta closed 5 months ago

RCasatta commented 1 year ago

From https://en.wikipedia.org/wiki/Uniform_Resource_Identifier

Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters.

Even though the canonical form is lowercase, the uppercase form should be ok since the schemes are case-insensitive.

There is a non-negligible advantage in using the scheme uppercase since would allow to keep to Alphanumeric mode for the first part of the URI

rust-bitcoin is using an uppercase scheme for bech32 addresses, https://github.com/rust-bitcoin/rust-bitcoin/blob/7c6a7c34b87fa92e6432247e3ce909333ef44d05/bitcoin/src/address.rs#L985 we should switch here too, or if there are good reasons to keep it lowercase upgrade rust-bitcoin to be coherent.

RCasatta commented 1 year ago

oh it looks my android phone is not considering the uppercase scheme correctly, so I think sadly we have to upgrade rust-bitcoin...

sbddesign commented 5 months ago

There is a non-negligible advantage in using the scheme uppercase since would allow to keep to Alphanumeric mode for the first part of the URI

We discussed this in this issue right here.

I collected a ton of data (shared in that issue's discussion), testing not only for wallet compatibility but also the size of the resultant QR. The tool I was using uses mixed modes, meaning it encodes some part of the string alphanumerically and others with whatever the most space efficient mechanism is.

So, my conclusion was to not uppercase the scheme because not many wallets supported it and when using mixed modes the size difference was negligible. See the data I shared in that discussion.

Willing to open the discussion again if my data is inaccurate or there are other relevant points we missed.

RCasatta commented 5 months ago

The tool I was using uses mixed modes, meaning it encodes some part of the string alphanumerically and others with whatever the most space efficient mechanism is.

That doesn't mean there wouldn't be space saving, a header switch would be saved, but yeah the advantages are small and disantvantages big, indeed I switched rust-bitcoin to encode the scheme lower-case