Hi all,

there is some discussion happening [1] about how to encode a PSBT in QR codes.

According to the specification (page 15 [2]) a version 40 QR code could contain up to 3706 bytes of data, however practical limitation are much lower and a PSBT could grow bigger anyway. so the issue is that a PSBT does not fit in 1 QR code.

There are proposals suggesting animated QR codes but I don't think it's a good idea for the following reasons:
* they are not easy to print
* it's not clear, by a human look, how much data it's being transferred, thus allowing more space for attacks
* old hardware may have resource constraint and not being able to scan

There are proposals suggesting alphanumeric mode for QR codes and a header (like message 1 of n) to allow data reconstruction. Main argument for this choices are:
* use of built-in standard scanner
* data is copypasteable
* not a big loose in efficiency comparing to binary with a proper encoding
* industrial QR code scanner put a \r at the end of transmission (making binary mode difficult to handle with timeouts or similar)

I don't think alphanumeric with custom headers it's a good idea and I think we should use binary encoding and using the already available mode in QR code specification called "structured append" (page 55 [2]). Corresponding counter-points are:
* since data need to be reconstructed, I would avoid built-in scanner and manual appending of strings anyway.
* we can keep the already used base64 for copypaste
* the best of the encoding we already have, bech32, is 10% less efficient than binary and if we want to be more efficient we need to introduce a new specific encoding
* I don't have a strong counter-point on industrial scanner, however if they use \r to signal end of transmission they don't support well binary at all, why they don't send how many bytes they read?

There are some doubts about support of structured append in QR code libraries which is not widely supported. While this is true I verified the widely diffused zxing library on Android and Luca Vaccaro verified the Apple built-in scanner, and both this libraries let's you access to the scanned raw bytes, allowing to parse the structured append header.
For reference, structured append allows to chain up to 16 qr codes, and contains 1 byte of parity.

[1] https://github.com/cryptoadvance/specter-diy/issues/57
[2] https://www.swisseduc.ch/informatik/theoretische_informatik/qr_codes/docs/qr_standard.pdf


--
Riccardo Casatta - @RCasatta