THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Payment QR Codes: Encoding, Address Validation, and Security

permalink THAMER
#bip21#bitcoin#payment-request#qr-code#security

A Bitcoin QR code is a visual container for data. It might encode a plain Bitcoin address, a BIP21 URI, or a payment instruction from another supported protocol. The QR image is not a cryptographic signature, proof of payment, or proof that the intended recipient created the request.

What is actually inside a QR code?

A basic code may contain a Bitcoin address such as a Bech32 or Bech32m destination. A richer code can contain a BIP21 request with amount, label, and message. A scanner reads the text, and wallet software interprets it according to the recognized format.

For example, a payment request may conceptually contain:

bitcoin:<validated-address>?amount=0.00010000&label=Coffee

This represents 10,000 sats requested by the payee. It does not include the transaction fee, and the placeholder must never be used as a real address. A wallet must parse the decimal amount exactly and apply the selected network's address validation.

Display before approval

Good wallet UX shows the final destination, requested amount, and estimated network fee separately. A QR scanner should not silently sign or broadcast after decoding. The payer must be able to reject unexpected changes, including a destination different from the one shown on the invoice.

Some wallets scan only addresses and may ignore or reject payment URI parameters. Others support multiple payment schemes. Compatibility should be tested rather than inferred from the fact that the camera recognized the QR symbol.

Common security failures

QR replacement is a straightforward redirection attack: a sticker, image swap, or malicious web component substitutes an attacker-controlled destination. Another risk is confusing a testnet address with a mainnet address. An attacker can also present a legitimate-looking label or message; these fields do not authenticate the merchant.

QR content can be large or malformed. Decoders and parsers should enforce size limits, reject invalid encodings, and avoid rendering untrusted text as executable HTML. The same safeguards apply when requests arrive through links or clipboard paste.

A practical verification checklist

Check that the decoded format is supported; confirm the network and address; parse the amount in satoshis without floating-point rounding; inspect the fee; and obtain explicit payment authorization. Finally, verify payment status from the Bitcoin network or the chosen payment protocol rather than from the QR itself.

Primary references

BIP21 — URI Scheme: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki
BIP173 — Base32 address format for native v0-16 witness outputs: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
BIP350 — Bech32m format: https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects