Sub topic 8
Signing offline: moving transactions, not keys
Prerequisites and scope
This chapter assumes you know what a private key and a public key are at a high level. It also assumes you have sent or received crypto from a wallet or exchange, and that you have seen the hot and cold wallet distinction from earlier chapters. Here you will learn how a transaction is prepared on a networked machine, signed on an offline machine, and broadcast afterward. The private key never leaves the offline device.
The core idea
A signature proves that the holder of a private key approved a specific transaction. Creating one needs only the key and the transaction data. It does not need the internet.
That fact allows a split of duties:
- The online machine knows the blockchain. It sees your coins (unspent outputs), computes fees, and can broadcast.
- The offline machine knows the key. It can sign, but it cannot see the network.
Only the transaction travels between them. The key stays where it is. This is why the chapter title says you move transactions, not keys.
The pattern is called air-gapped signing. An air gap means there is no network link of any kind between the signer and the outside world: no Wi-Fi, Bluetooth, or cable to a networked computer. Data crosses the gap only through media you choose, such as a QR code, an SD card, or a USB stick used as a plain data carrier.
The three roles
The workflow separates three jobs. One machine can do more than one of them, but the security benefit comes from keeping the signer separate.
| Role | What it does | Needs the private key? | Needs the network? |
|---|---|---|---|
| Watch-only wallet (online) | Tracks balances, picks coins, builds the unsigned transaction | No | Yes |
| Signer (offline) | Checks the transaction and adds signatures | Yes | No |
| Broadcaster (online) | Finalizes the signed transaction and sends it to the network | No | Yes |
A watch-only wallet is built from public information only: an extended public key or a set of addresses. It can show you incoming payments and prepare spends. It cannot move a single satoshi on its own. If malware takes over the online machine, the attacker learns your balances and addresses, which is a privacy loss. The attacker cannot spend your funds.
The PSBT format
To pass a half-finished transaction between machines, wallets use a shared format. On Bitcoin that format is the Partially Signed Bitcoin Transaction, or PSBT, defined in BIP 174. A PSBT is a container that holds:
- the unsigned transaction (inputs and outputs),
- extra data the signer needs, such as the previous transactions or amounts being spent and the derivation paths of the keys involved,
- space for signatures as they are added.
Because the format is standard, a watch-only wallet from one project can often hand a PSBT to a hardware wallet from another. A PSBT is usually shown as base64 text, stored as a file, or split into animated QR codes when it is too large for one.
The flow end to end
The diagram below shows who does what, and what crosses the air gap.
Step by step with Bitcoin Core
Bitcoin Core supports this flow through its PSBT commands. The example below uses two wallets: watchonly, which holds no private keys, and cold, which does and runs on an offline machine.
# On the online machine, using a watch-only wallet (it holds no private keys).
# Replace the placeholder address and amount with your own values.
bitcoin-cli -rpcwallet=watchonly walletcreatefundedpsbt '[]' '[{"<destination_address>": 0.01}]'
# Copy the returned "psbt" string to the offline signer (for example by file or QR code).
# On the offline machine, whose wallet holds the private keys:
bitcoin-cli -rpcwallet=cold walletprocesspsbt "<psbt_string>"
# Bring the signed PSBT back to the online machine, finalize it and broadcast it:
bitcoin-cli finalizepsbt "<signed_psbt_string>"
bitcoin-cli sendrawtransaction "<final_hex>"Each command does one job:
walletcreatefundedpsbtselects coins from the watch-only wallet, adds a change output, and sets the fee. It returns a JSON object containing thepsbtstring.walletprocesspsbtruns on the offline machine. It adds signatures for every input thecoldwallet can sign.finalizepsbtturns the signatures into the final transaction. Its JSON output contains ahexfield and acompleteflag. Check thatcompleteistruebefore continuing.sendrawtransactiontakes that hex and relays it to the network.
In practice, the offline machine also needs a way to receive the PSBT and return the signed one. Many people use a removable drive or QR codes for this. Treat any removable drive as untrusted input: copy only the PSBT file, and keep that drive for this purpose alone.
What the signer must verify
Signing offline is only as safe as the check the user performs. A signer that signs whatever it receives would let a compromised online machine drain the wallet. The offline device must show you the facts that matter, and you must read them.
Check these on the signer's own screen, not on the online computer:
- Destination address. Compare it with the address you intended, character by character, or at least the start and end plus a middle section.
- Amount. Confirm the amount sent to the destination.
- Change output. The signer should recognize the change address as belonging to your wallet. If it shows change going to an unknown address, stop.
- Fee. An unusually large fee is a common sign of tampering or a mistake. The fee is the difference between inputs and outputs, and a signer can compute it only if it knows the input amounts.
That last point has a technical edge case. Older signers could not verify input amounts for some script types, which let a malicious online machine lie about the fee. Modern PSBT workflows include the full previous transaction or the amount data, and current hardware wallets check them. Keep your signer's firmware up to date, as a later chapter on operational hygiene covers.
Variants of the transfer method
How the PSBT crosses the gap changes the attack surface.
| Method | How it works | Main risk | Notes |
|---|---|---|---|
| QR codes | Online screen shows animated QR, offline camera scans it | Very small. The signer parses only image data | Slow for large transactions with many inputs |
| SD card | Files are copied by a card reader | The signer must parse a file system and the file | Use a dedicated card |
| USB cable to a hardware wallet | Wallet software on a computer talks to the device | The device is connected to a possibly infected host | Not strictly air-gapped, but the key still never leaves the device |
| Bluetooth | Wireless link to a phone app | Larger wireless attack surface | Convenient, weaker isolation |
A USB hardware wallet is a related but distinct case. The device is not air-gapped, yet the key is generated inside it and cannot be exported. The security rests on the device's design and its screen. A strict air gap removes the host connection entirely, trading convenience for a smaller attack surface.
Where this fits in a tiered setup
Offline signing adds friction to every spend. You must fetch the offline device, move data across, check the screen, and carry it back. For a small spending balance that friction is not worth it, which is why earlier chapters keep a capped hot wallet. For savings you rarely touch, the friction is the point.
The tiering rule from the strategy chapter can be written as code. This function returns how many satoshis to move from the hot wallet to cold storage:
def plan_rebalance(hot_sats, hot_cap_sats, hot_target_sats):
"""Return how many satoshis to move from the hot wallet to cold storage.
If the hot balance is at or below the cap, nothing moves.
Otherwise, move enough to bring the hot wallet back to its target.
"""
if hot_target_sats > hot_cap_sats:
raise ValueError("target must not exceed cap")
if hot_sats <= hot_cap_sats:
return 0
return hot_sats - hot_target_sats
print(plan_rebalance(hot_sats=5_000_000, hot_cap_sats=2_000_000, hot_target_sats=500_000)) # 4500000
print(plan_rebalance(hot_sats=1_000_000, hot_cap_sats=2_000_000, hot_target_sats=500_000)) # 0Moving funds into cold storage never needs the offline signer, because you only send to a cold address. The signer is needed only when you move funds out of cold storage. Offline signing therefore tends to be rare, which also means you may forget how it works. Practice with a small amount first.
Common errors
- Signing without reading the screen. The most damaging mistake. See the warning above.
- Confusing a watch-only wallet with a backup. A watch-only wallet cannot recover funds. Your seed phrase backup is still required.
- Skipping the test spend. The first time you use the flow should not be with your full savings. Send a small amount to the cold address, then spend it back using the whole procedure.
- Importing private keys into the online machine to "fix" a failed signing. This defeats the whole design. Fix the PSBT transfer instead.
- Reusing the offline machine for other tasks. Installing general software, browsing, or plugging in unknown devices removes the isolation you built.
- Mismatched derivation data. If the watch-only wallet was created from the wrong extended public key, the signer may not recognize the inputs and will refuse to sign. Re-export the public key from the signer and rebuild the watch-only wallet.
- Treating an incomplete PSBT as final. With multisignature setups, a PSBT may need several signers.
finalizepsbtreportscomplete: falseuntil enough signatures exist.
Summary of the trust model
| Component | If compromised | Funds at risk? |
|---|---|---|
| Online watch-only machine | Attacker sees balances, can build a malicious PSBT | Only if you approve a bad transaction without checking |
| Transfer medium | Attacker can swap or alter a PSBT in transit | Same as above, the signer's screen is the defense |
| Offline signer (software or firmware) | Attacker may obtain the key or sign silently | Yes |
| Offline signer physically stolen | Attacker holds the device | Depends on PIN or passphrase protection |
The design concentrates trust in one small place, the signer, and keeps the large and exposed parts of the system unable to spend.
Exercise
You build a PSBT on your online watch-only wallet and carry it to your offline signer. The signer's screen shows a destination address that differs from the one you intended, and the online computer's screen shows the correct one. Which screen do you trust, what do you do, and why does offline signing not prevent this attack?
Show answer
Trust the signer's screen, because the online computer may be compromised and can display anything. Reject the transaction without signing, then investigate the online machine (scan it, or move to a clean one) before building a new PSBT. Offline signing protects the private key, not the content of the transaction. The online machine builds the transaction, so malware there can substitute an attacker's address. The only defense is that you read and verify the details on the signer.
Exercise
A friend says, "My cold wallet is safe because my watch-only wallet on my laptop has all my addresses and keys." What is wrong with this statement, and what does the watch-only wallet actually hold?
Show answer
A watch-only wallet holds only public information, such as an extended public key or addresses, and no private keys. It can show balances and build unsigned PSBTs but cannot sign or spend. The statement is wrong in saying it has the keys. It is also misleading to call this a backup: if the offline device is lost, the watch-only wallet cannot recover the funds, so the seed phrase backup is still essential.