How to create QR codes for onchain transactions with embedded messages?

3 replies 150 views
Posts: 1 · Reputation: 40
#1Aug 20, 2022, 03:31 AM
I've been stuck on this for the past few days. I'm trying to make a QR code that bitcoin wallets can easily read, which includes a transaction and an embedded message that goes onchain. Right now, I'm using OP_RETURN for this, and my code seems fine. But I’m hitting a wall because none of the QR codes I create are recognized by wallets like Blockstream Green. I also tried BIP21 and added a message field, but as far as I know, that doesn’t actually post the data onchain. I really need it to be onchain this option worked with Green, but I haven't tested with others. Then I looked into PSBT, but it seems like I need the sender's address from the user beforehand, which is a deal-breaker since it complicates the user experience too much. What other possibilities do I have? Looking for something that wallets widely support.
4 Reply Quote Share
hash_bossLegendary
Posts: 1166 · Reputation: 5261
#2Aug 20, 2022, 08:20 AM
Probably none, partly because many wallet don't have feature to create OP_RETURN output. But FWIW, BIP 321 is probably closest thing you're looking for. It has message key[1], but it's very likely it refer to message shown on user device. So what you could use is otherparam, that could be used for your purpose and suggest other wallet to support your key/otherparam. [1] https://github.com/bitcoin/bips/blob/master/bip-0321.mediawiki#query-keys [2] https://github.com/bitcoin/bips/blob/master/bip-0321.mediawiki#abnf-grammar
4 Reply Quote Share
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#3Aug 20, 2022, 02:32 PM
Theoretically, with the proper "SIGHASH Flag", the recipient may issue an already created PSBT with the OP_RETURN output and an input that the recipient provided, containing signatures. Then have the sender combine it with his PSBT that pays the URI. However, this requires the recipient to shoulder part of the transaction fee and the OP_RETURN output. And including both PSBT and URI in the same QR Code isn't standardized. References: developer.bitcoin.org/reference/rpc/combinepsbt.htmldeveloper.bitcoin.org/devguide/transactions.html?highlight=sighash#signature-hash-types
2 Reply Quote Share
s33d_moonFull Member
Posts: 235 · Reputation: 715
#4Aug 20, 2022, 07:27 PM
Going by my findings what you want doesn't exist in a wallet-agnostic way There’s no widely adopted QR standard for embedding arbitrary on-chain data. If there were, it would already be abused which is why most wallets simply won’t construct OP_RETURN transactions from QR input. BIP21 doesn’t commit data, PSBT adds too much friction and anything else means controlling the signing flow yourself. If wide wallet support matters you’re limited to the small set of QR features wallets deliberately expose. References https://en.bitcoin.it/wiki/BIP_0021https://developer.bitcoin.org/devguide/payment_processing.html?
3 Reply Quote Share

Related topics