ElementsProject / cln-application

Official core lightning application by Blockstream
MIT License
30 stars 8 forks source link

Uppercase Lightning Invoice is Invalid #66

Closed afxsoftware closed 1 week ago

afxsoftware commented 2 months ago

This is my first contribution to open source. Go easy on me.

From the lightning wallet, click on Send. Select Invoice. Enter a lightning address that's all UPPERCASE characters. Phoenix wallet generates all uppercase addresses. The UI responds with Invalid Invoice.

The issue is in CLNSend.tsx on line 37. Here is a simple fix. const isValidInvoice = (value) => value.trim() !== '' && (paymentType === PaymentType.KEYSEND || (paymentType === PaymentType.INVOICE && value.toLowerCase().startsWith('lnb')) || (paymentType === PaymentType.OFFER && value.toLowerCase().startsWith('lno')));

evansmj commented 1 month ago

Thanks for bringing this up. I checked on Android and the invoice is lowercase. On iOS, it is uppercase like you observed.

We should check if this is valid to the spec or not and either submit an issue to Phoenix wallet iOS or allow uppercase here.

evansmj commented 1 month ago

https://github.com/lightning/bolts/blob/master/11-payment-encoding.md

BIP-0173

Uppercase/lowercase

The lowercase form is used when determining a character's value for checksum purposes.

Encoders MUST always output an all lowercase Bech32 string. If an uppercase version of the encoding result is desired, (e.g.- for presentation purposes, or QR code use), then an uppercasing procedure can be performed external to the encoding process.

Decoders MUST NOT accept strings where some characters are uppercase and some are lowercase (such strings are referred to as mixed case strings).

For presentation, lowercase is usually preferable, but inside QR codes uppercase SHOULD be used, as those permit the use of [alphanumeric mode](http://www.thonky.com/qr-code-tutorial/alphanumeric-mode-encoding), which is 45% more compact than the normal [byte mode](http://www.thonky.com/qr-code-tutorial/byte-mode-encoding).

it looks like this is valid, and that we should update cln-application to support this.

@afxsoftware are you able to make a pull request with your change? You can fork this repository, make the change, and submit a pull request via https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork if you would like to make the contribution yourself.

afxsoftware commented 1 month ago

Yes, I'll make a pull request.