Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified QR scanning #755

Merged
merged 1 commit into from
Jan 17, 2024
Merged

Unified QR scanning #755

merged 1 commit into from
Jan 17, 2024

Conversation

benalleng
Copy link
Contributor

adds support for scanning bip21 qrs on withdrawal.

I didn't really make an attempt to add any substantial bip21 support as we only use it for finding the lightning param.

Closes #734

@ekzyis
Copy link
Member

ekzyis commented Jan 16, 2024

Welcome first-time contributor :)

Changes look good, I will test them today. Thanks in advance!

Btw, you can add your SN nym to contributors.txt if you want to have verified stacker.news contributor in your SN profile (assuming you're on SN). For example, see my profile.

Can you also format/lint your code? Our CI failed because of this:

Run npm run lint

> [email protected] lint
> standard

standard: Use JavaScript Standard Style (https://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.
  /home/runner/work/stacker.news/stacker.news/pages/wallet.js:281:38: Trailing spaces not allowed. (no-trailing-spaces)
  /home/runner/work/stacker.news/stacker.news/pages/wallet.js:283:[4](https://github.com/stackernews/stacker.news/actions/runs/7537135803/job/20532278497?pr=755#step:5:5)[9](https://github.com/stackernews/stacker.news/actions/runs/7537135803/job/20532278497?pr=755#step:5:10): Strings must use singlequote. (quotes)
Error: Process completed with exit code 1.

@ekzyis ekzyis added the feature new product features that weren't there before label Jan 16, 2024
@benalleng benalleng force-pushed the bip21-qr branch 2 times, most recently from e13972b to 0e36b3d Compare January 16, 2024 16:21
pages/wallet.js Show resolved Hide resolved
@ekzyis
Copy link
Member

ekzyis commented Jan 17, 2024

Tested the code manually with a unified invoice that Mutiny generated since I wasn't able to reliably scan the QR code with my webcam [0]

Welcome to Node.js v21.4.0.
Type ".help" for more information.
> result = "bitcoin:bc1plrevlm0tr0yccfg499hgrl57u0fc7lnwupqcu9qpssd845lzrt5skcx9xz?amount=0.00001&lightning=lnbc10u1pj6wfs4dqqpp52gw5tjtfaahkws2lv2s8lmfgyr34h9nv5z2nqgs7p9lt88g4w9mssp5guyscxept4v92rjamz2sxuj0qu8t92gdqklc98ja9fe0u8u6g22q9qrsgqcqpjnp4q05axhx0lmcwhhg53d20nzmwmh3ugzkqf7n6xsfrhcvwchjznwqesxqrrssrzjq25kye844yxfwqs4fck9qf6p6apclwa0ns28362gtg5q8kz5l4t5xqqqqqqqqqqqqyqqqqqqqqqqqqqqrcckcl7dtwdx30hmwrhalsrrrup9wx66vvnulh4ymzy7kdd4yccv6jl4my5msswp48jqd7wkq09hq47akn2ctzmk6av9kc5pus67rw56gpxzl7m8"
'bitcoin:bc1plrevlm0tr0yccfg499hgrl57u0fc7lnwupqcu9qpssd845lzrt5skcx9xz?amount=0.00001&lightning=lnbc10u1pj6wfs4dqqpp52gw5tjtfaahkws2lv2s8lmfgyr34h9nv5z2nqgs7p9lt88g4w9mssp5guyscxept4v92rjamz2sxuj0qu8t92gdqklc98ja9fe0u8u6g22q9qrsgqcqpjnp4q05axhx0lmcwhhg53d20nzmwmh3ugzkqf7n6xsfrhcvwchjznwqesxqrrssrzjq25kye844yxfwqs4fck9qf6p6apclwa0ns28362gtg5q8kz5l4t5xqqqqqqqqqqqqyqqqqqqqqqqqqqqrcckcl7dtwdx30hmwrhalsrrrup9wx66vvnulh4ymzy7kdd4yccv6jl4my5msswp48jqd7wkq09hq47akn2ctzmk6av9kc5pus67rw56gpxzl7m8'
> result.startsWith("bitcoin:")
true
> result.split("lightning=")
[
  'bitcoin:bc1plrevlm0tr0yccfg499hgrl57u0fc7lnwupqcu9qpssd845lzrt5skcx9xz?amount=0.00001&',
  'lnbc10u1pj6wfs4dqqpp52gw5tjtfaahkws2lv2s8lmfgyr34h9nv5z2nqgs7p9lt88g4w9mssp5guyscxept4v92rjamz2sxuj0qu8t92gdqklc98ja9fe0u8u6g22q9qrsgqcqpjnp4q05axhx0lmcwhhg53d20nzmwmh3ugzkqf7n6xsfrhcvwchjznwqesxqrrssrzjq25kye844yxfwqs4fck9qf6p6apclwa0ns28362gtg5q8kz5l4t5xqqqqqqqqqqqqyqqqqqqqqqqqqqqrcckcl7dtwdx30hmwrhalsrrrup9wx66vvnulh4ymzy7kdd4yccv6jl4my5msswp48jqd7wkq09hq47akn2ctzmk6av9kc5pus67rw56gpxzl7m8'
]
> result.split("lightning=")[1].split(/[&?]/)
[
  'lnbc10u1pj6wfs4dqqpp52gw5tjtfaahkws2lv2s8lmfgyr34h9nv5z2nqgs7p9lt88g4w9mssp5guyscxept4v92rjamz2sxuj0qu8t92gdqklc98ja9fe0u8u6g22q9qrsgqcqpjnp4q05axhx0lmcwhhg53d20nzmwmh3ugzkqf7n6xsfrhcvwchjznwqesxqrrssrzjq25kye844yxfwqs4fck9qf6p6apclwa0ns28362gtg5q8kz5l4t5xqqqqqqqqqqqqyqqqqqqqqqqqqqqrcckcl7dtwdx30hmwrhalsrrrup9wx66vvnulh4ymzy7kdd4yccv6jl4my5msswp48jqd7wkq09hq47akn2ctzmk6av9kc5pus67rw56gpxzl7m8'
]
> result.split("lightning=")[1].split(/[&?]/)[0].toLowerCase()
'lnbc10u1pj6wfs4dqqpp52gw5tjtfaahkws2lv2s8lmfgyr34h9nv5z2nqgs7p9lt88g4w9mssp5guyscxept4v92rjamz2sxuj0qu8t92gdqklc98ja9fe0u8u6g22q9qrsgqcqpjnp4q05axhx0lmcwhhg53d20nzmwmh3ugzkqf7n6xsfrhcvwchjznwqesxqrrssrzjq25kye844yxfwqs4fck9qf6p6apclwa0ns28362gtg5q8kz5l4t5xqqqqqqqqqqqqyqqqqqqqqqqqqqqrcckcl7dtwdx30hmwrhalsrrrup9wx66vvnulh4ymzy7kdd4yccv6jl4my5msswp48jqd7wkq09hq47akn2ctzmk6av9kc5pus67rw56gpxzl7m8'

However, I was able to scan it once and it entered some numbers into the invoice field. Not sure if that's relevant, it's probably just my webcam being bad.

But @huumn mentioned a good point here. User feedback in cases where we can detect they are doing something wrong (trying to scan onchain invoices for SN which is a LApp) sounds like the way to go.

[0] because my webcam produces unsharp images, I assume.

@benalleng benalleng force-pushed the bip21-qr branch 4 times, most recently from cc2b09a to a92b493 Compare January 17, 2024 14:22
pages/wallet.js Outdated Show resolved Hide resolved
@huumn huumn merged commit f915b2b into stackernews:master Jan 17, 2024
1 check passed
@huumn
Copy link
Member

huumn commented Jan 17, 2024

Merged! Feel free to add your nym to contributors.txt in another PR.

Also send me your lightning address when you get a chance so I can send you some sats when this ships.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new product features that weren't there before
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support unified QR codes on withdrawal
3 participants