Closed gorazdko closed 4 years ago
Sounds amazing! I think it's the right way to go. So awesome what you are doing!
I tried it out, specter-desktop part works great, but I wasn't able to scan it with specter-diy. Not sure why yet, I need to look into your code and understand the logic. Looks like it doesn't even try to scan multiple codes, not sure why.
I will get back to it later tonight and look carefully.
Ok I was stupid... Frozen firmware ignored python files )))
Works like a charm!!! Beeps a few times and imports the wallet - very nice feeling! I like it!
I tried it out, specter-desktop part works great
the qrcode library is not ok. it has a bug: https://github.com/davidshimjs/qrcodejs/issues/220
You will notice it when changing max_len
when having QRCode.CorrectLevel.H
I need to look into your code and understand the logic
i will write a couple of sentences later about how this works, the limitations and other things i noticed...
The barcode scanner works in continuous mode with INTERVAL_OF_SCANNING 100ms. This means after it obtains a scan it waits 100ms and starts a new scan. The scan itself usually lasts much longer - the more data it encodes, the longer it lasts. No external trigger is necessary to initiate a scan. We stop scanning by changing the scan mode to command mode.
DELAY_OF_SAME_BARCODES of 5 seconds means scanning the same barcode again (and sending it over uart) can happen only when the interval elapses. The interval either times out or resets if we scan a different qr code.
interval of animating 300ms, 200byte frames , qrCorrectionLevel=L
If our hand is not still and PSBT transaction is very large we can wait several rounds (and one round can get big, perhaps even 20 frames) until all the frames are scanned. Bad UX, can get frustrating. Also, if the scanner is not focused accurately on the qr code, the scanning speed can slow down dramatically.
I can make this into a PR if we decide we want this. It still has some bugs that i need to fix (e.g. buffer overflow when scanning multiple rounds etc.) and do some code cleanup. But it would also break the support for the other scanner (which i dont have) which specter diy uses.
Regarding specter desktop, i can find a better frontend qrcode library and push the changes without buttons. The current backend qr library is not suitable as the qr code animation is a frontend process.
I think we should use animated QR codes only when it is super necessary - rare transactions with many inputs and outputs, very large multisig wallets.
With current PSBT optimizations even a large multisig fits in one QR codes if there are not too many inputs and outputs. And if people want to make a huge transaction, they should be ready to hold their wallet still for quite some time )))
Let's make it into a pull request.
For specter-desktop I suggest to add a checkbox or button animate QR code
. So normally QR code is large and shows full data, but if you check the checkbox it becomes smaller and animated.
The same for signed psbt QR code in specter-diy - we have enough space to add a checkbox that would animate the QR code. By default let's keep it static.
Abstract
I did a proof of concept for scanning animated qrs automatically (without buttons): https://github.com/gorazdko/specter-diy/tree/animiated_qr_video
Animations can be played with https://github.com/gorazdko/specter-desktop/tree/qr_animation
def qr_animate(qrtext, max_len=100):
max_len determines the maximum chunk size of the framewindow.setInterval(function(){full_psbt.qra_next()}, 250)
QRCode.CorrectLevel.H
Results
Its feasible, though results arent nearly as good as in https://divan.dev/posts/animatedqr/ where
Here, one setting that works ok is 250 ms interval with 100 byte frames. For optimal settings one should play with parameters
Should we prefer this method over the one with buttons?