Update 03_6_Creating_QR_Codes_for_Addresses.md

This commit is contained in:
Shannon Appelcline 2026-02-19 14:44:16 -10:00 committed by GitHub
parent 6ee262de9d
commit d60d3e7b84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,28 +1,28 @@
# 3.6: Creating QR Codes for Addresses
To date we've been displaying addresses as little bits of bech32- and base58-encoded data. That's great if you can cut and paste them or if you can store them in shell variables. But what if you're trying to transmit an address between devices that aren't on the same network, or that don't have a direct connection even if they are. That's where QR Codes come into play.
To date we've been displaying addresses as little bits of bech32- and base58-encoded data. That's great if you can cut and paste them or if you can store them in shell variables. But what if you're trying to transmit an address between devices that aren't on the same network, or that don't have a direct connection even if they are? That's where QR Codes come into play.
## The Power of Airgaps
When you have two devices that don't directly talk to each other you have an [airgap](https://developer.blockchaincommons.com/airgap/). It can be created purposefully, it could be a result of a device's limitations, or it could be part of a designed architecture. Here are some common situations that involve airgaps:
When you have two devices that don't directly talk to each other you have an [airgap](https://developer.blockchaincommons.com/airgap/). It could be created purposefully, it could be a result of a device's limitations, or it could be part of a designed architecture. Here are some common situations that involve airgaps:
* _Your mobile device tends to be airgapped from other devices._ Sure, it can talk to the internet, and it's been taught to talk to your printers, but the ways in which you can talk to your computer or your tablet tend to be extremely restricted.
* _Your mobile device tends to be airgapped from other peoples' mobile devices._ Again, there may be a few ways they can talk, such as exchanging contact information, but they're limited.
* _Hardware wallets tend to be airgapped from everything._ Some older wallets allowed you to connect up to a computer with a single cord, but many newer wallets have done away with even that.
This isn't just an annoyance (though it often is!). It's also a powerful security feature. Airgaps constrain transmission, they eliminate interactivity, and they highlight user agency. These are advantages that make it much harder for a device to be attacked by a virus or an active adversary across an Airgap. For that reason many self-sovereign wallets, which allow users to safely hold their own funds rather than trusting an exchange, are airgapped.
This isn't just an annoyance (though it often is!). It's also a powerful security feature. Airgaps constrain transmission, they eliminate interactivity, and they highlight user agency. These are advantages that make it much harder for a device to be attacked by a virus or an active adversary. For that reason, many self-sovereign wallets, which allow users to safely hold their own funds rather than trusting an exchange, are airgapped.
## The Power of QR Codes
The advantages of airgapping raise an obvious question: how do you get data to and from an airgapped device? Traditionally this was done with "sneakernet", which meant copying the data onto a floppy disk and carrying across the airgap. More recently, the same effect can be accomplished with an SD card or an NFC card.
The practice of airgapping raise an obvious question: how do you get data to and from an airgapped device? Traditionally this was done with "sneakernet", which meant copying the data onto a floppy disk and carrying it across the airgap. More recently, the same effect can be accomplished with an SD card or an NFC card.
QR Codes can also be used to carry content across airgaps. A QR Code, or Quick Response code, is simply a two-dimensional bar code. It contains data in its lines and dots and has three squares at three of the corners, which cameras can use to figure out the edges of the QR Code and flatten it out so that it can be read correctly. And QR Codes can contain a surprising amount of information: 2,953 bytes that can be freely input. You put all of that together and you have an excellent mechanism for transmitting Bitcoin information across airgaps: you just show a QR Code on one device, and you read that code with a camera on the other.
QR Codes can also be used to transmit content across airgaps. A QR Code, or Quick Response code, is simply a two-dimensional bar code. It contains data in its lines and dots and has three squares at three of the corners, which cameras can use to figure out the edges of the QR Code and flatten it out, so that it can be read correctly. These QR Codes can contain a surprising amount of information: 2,953 bytes that can be freely input. You put all of that together and you have an excellent mechanism for transmitting Bitcoin information across airgaps: you just show a QR Code on one device, and you read that code with a camera on the other.
## Setup qrencode
## Set Up qrencode
One of the simplest methods for encoding data as a QR Code is the `qrencode` program, which is available for a variety of playforms on the internet.
One of the simplest methods for encoding data as a QR Code is the `qrencode` program, which is available for a variety of playforms from the internet.
If you setup your machine with the Bitcoin Standup Scripts, as we suggest, you already have it.
If you set up your machine with the Bitcoin Standup Scripts, as we suggest, you already have it.
```
$ which qrencode
/usr/bin/qrencode
@ -32,7 +32,7 @@ $ which qrencode
## Encode Addresses with qrencode
One of the most common uses of QR Coins in Bitcoin is to encode addresses. This is as simple as outputting your `getnewaddress` command to `qrencode` and then outputting (`-o`) that to a file:
One of the most common uses of QR Coins in Bitcoin is to encode addresses. This can be as simple as outputting your `getnewaddress` command to `qrencode` and then outputting (`-o`) that to a file:
```
$ bitcoin-cli getnewaddress | qrencode -o newaddress.jpg
$ ls -la newaddress.jpg
@ -50,7 +50,7 @@ First, decode it and see what it really says. This can often be done with a mobi
<a href="/images/03-qraddress-photo.jpg"><img src="/images/03-qraddress-photo.jpg" width=250></a>
Second, check the text of the QR with the person who sent it to you. For addresses, checking the first several and last several addresses can be enough. In this case the QR sender could check the address against his wallet with `getaddressesbylabel` and see that `tb1qguyxx...93xk3nhu` is indeed in there.
Second, check the text of the QR with the person who sent it to you. For addresses, checking the first several and last several addresses can be enough. In this case, if asked, the QR sender could verify the address against their wallet with `getaddressesbylabel` and see that `tb1qguyxx...93xk3nhu` is indeed in there.
```
$ bitcoin-cli getaddressesbylabel ""
@ -77,15 +77,15 @@ $ bitcoin-cli getaddressesbylabel ""
QRs can have other uses in Bitcoin work.
The [Quick Connect](https://developer.blockchaincommons.com/quickconnect/) protocol allows a network coordinator (that's the `bitcoin-cli` or other server that actually talks to the Bitcoin network) to securely link to a Seed Vault (that's the airgapped hardware device where seeds or keys are actually stored. Though we'll be doing a lot of work in this course where we're just passing variables around on the command line, a real-world Bitcoin setup has much more sophisticated separation of data of this sort.
The [Quick Connect](https://developer.blockchaincommons.com/quickconnect/) protocol allows a network coordinator (that's the `bitcoin-cli` or other server that actually talks to the Bitcoin network) to securely link to a Seed Vault (that's the airgapped hardware device where seeds or keys are actually stored). Though we'll be doing a lot of work in this course where we're just passing variables around on the command line, a real-world Bitcoin setup requires much more sophisticated separation of data of this sort for security.
QRs can also be used to pass complex transactions called PSBTs among multiple members of a multisig. However, QRs are very large, so they require a different sort of QR called [animated QRs](https://developer.blockchaincommons.com/animated-qrs/). There's more on PSBTs and animated QRs in [chapter 7](07_0_Expanding_Bitcoin_Transactions_PSBTs.md).
QRs can also be used to pass complex transactions called PSBTs among multiple members of a multisig. However, PSBTs are very large, so they require a different sort of QR called [animated QRs](https://developer.blockchaincommons.com/animated-qrs/). There's more on PSBTs and animated QRs in [chapter 7](07_0_Expanding_Bitcoin_Transactions_PSBTs.md).
Fundamentally, any time you have non-human-readable data that you want to transmit between two devices without a direct connection, a QR Code is a great option. (But, one that we largely won't see again in this course, because we're of course working on the _command line_.)
Fundamentally, any time you have non-human-readable data that you want to transmit between two devices without a direct connection, a QR Code is a great option. (But, it's one that we largely won't see again in this course, because we're of course working on the _command line_.)
## Summary: Creating QR Code for Addresses
You won't be creating more QR Codes in this course (except when we briefly touch upon Animated QR Codes). However, QR Codes are a vital part of the largely Bitcoin ecosystem because they allow you to transmit data across airgaps, which could be important for distributing addresses to people sending you money or for colelcting together signatures for a PSBT. And, as it happens, you can create them right from the command line with the `qrencode` tool.
You won't be creating more QR Codes in this course (except when we briefly touch upon Animated QR Codes). However, QR Codes are a vital part of the larger Bitcoin ecosystem because they allow you to transmit data across airgaps, which could be important for distributing addresses to people sending you money or for collecting together signatures for a PSBT. And, as it happens, you can create them right from the command line with the `qrencode` tool.
## What's Next?