PSBTs
How a transaction travels from Liana to each signing device and back before Liana broadcasts it.
Your signing devices hold your keys but cannot see your coins, which Liana tracks. What goes between them, over USB or on an SD card, is a PSBT, or Partially Signed Bitcoin Transaction.
A PSBT carries what a signer needs to check
An unsigned transaction names the coins it spends by their outpoint, and lists the outputs it creates. It does not say how much each coin holds, or which script locks it. A signing device cannot check a payment from that alone.
BIP 174 defines the PSBT to fill that gap. A PSBT holds the unsigned
transaction, then one map of extra fields per input and one per output.
Signatures land in the input maps as they arrive. Every PSBT starts with the
bytes psbt and 0xFF, so a PSBT written as base64 text starts with
cHNidP.
In the roles BIP 174 defines, lianad creates the PSBT, combines the
signatures, and finalizes it. Your signing devices and the
hot signer only sign. With
Liana Connect, its server builds, stores, and broadcasts
the PSBTs instead of lianad.
Liana works in version 0 only
BIP 370 defines a version 2, where inputs and outputs can join a PSBT after
its creation. lianad builds the whole transaction at once and writes
version 0. Importing a version 2 file into Liana fails, with
ImportExport: fail to parse PSBT when the file is base64 text.
The Bitcoin app on a Ledger reads only version 2, so the library Liana uses for Ledgers converts the PSBT on its way over USB. It then copies the signatures back into Liana's version 0 copy.
What Liana writes for your signing devices
What lianad adds for the signer depends on the
script type:
| PSBT map | SegWit (P2WSH) wallet | Taproot (P2TR) wallet |
|---|---|---|
| Each input | The coin's amount and script, the previous transaction that created it, the witness script, the fingerprint and derivation path of each key | The coin's amount and script, the internal key, the Merkle root, each leaf script with its control block, the fingerprint and derivation path of each key |
| Each output to your wallet | The fingerprint and derivation path of each key | The internal key, the script tree, the fingerprint and derivation path of each key |
The previous transaction protects P2WSH inputs. A P2WSH signature commits to the
amount of its own coin only. BIP 174 warns that software can lie about the
other amounts. A device asked to sign more than once can then be tricked into
paying bitcoin in fees. A Taproot signature commits to the amount of every
input, so lianad leaves that transaction out.
A PSBT reveals your wallet's policy
A PSBT holds no private key. It shows the addresses, the amounts, and the script of each coin it spends, with every public key and timelock of your spending paths. Share it only over a private channel.
The life of a transaction in Liana
Liana builds the draft
You fill in Send or Recovery. lianad builds the PSBT. For a
recovery transaction, it declares the path's
timelock
in each input. Liana does not store the PSBT yet.
Liana stores it under Drafts & approvals
When you select Save, or sign for the first time, Liana stores the PSBT
under Drafts & approvals. lianad keeps it in lianad.sqlite3, indexed by
its txid. SegWit keeps signatures out of the data the txid hashes, so the
draft's txid, under Tx ID:, stays the same through signing and on-chain.
Each signing device adds its signatures
- Over USB: Select Sign, then the device under Select signing device to sign with:. The hot signer signs from the same window.
- As a file: Select Export in the Signatures card of a saved
draft. Liana writes base64 text to a file named
psbt.psbtby default, which an SD card carries to a Coldcard or a Krux. Import brings the signed file back, as Sign air-gapped shows.
Liana merges the signatures
Liana keeps its own copy as the reference. From each signed PSBT, it takes
only the signatures, input by input, and adds them to that copy. The devices
can sign in any order. A file for another transaction fails with
The imported PSBT txid doesn't match this PSBT.
lianad finalizes and broadcasts
Once one spending path has all its signatures, and its timelock, if any, has
expired, Broadcast replaces Sign.
When you confirm the broadcast, lianad finalizes the PSBT.
Miniscript builds the witness of each input from the
signatures and the scripts, and checks every signature it uses. lianad then
passes the transaction to your
backend. With Liana Connect, Liana asks its server to broadcast instead.
What a signing device checks before it signs
BIP 174 lets a signing device sign from the PSBT alone. Two of its required checks matter here:
- A witness script matches the script of the coin it spends.
- A previous transaction hashes to the txid its input points to.
A signing device with a screen can also compute the addresses, amounts, and fee to show you. To hide your change, it rebuilds the script of each output from its derivation paths and compares it with your wallet's policy. The Descriptor registration page explains how a device learns that policy.
Malware on your computer can alter Liana's screen, not the device's. Read the payment there before you approve, as Send bitcoin shows.
Liana reads a draft's status from its signatures and its coins
| Liana shows | What it means |
|---|---|
Unsigned | No spending path has all its signatures. The Signatures card counts the signatures of the path the draft spends through, such as 1 of 2, and lists the keys that can still sign. |
To broadcast | One spending path has all its signatures, from the keys listed after Signed by, and its timelock, if any, has expired. |
Timelocked | A recovery path has all its signatures, but its timelock has not expired for at least one coin the draft spends. Liana shows neither Sign nor Broadcast. |
1/2, or 1/2 signatures collected when the window is wide enough, in Drafts & approvals | Signatures the spending path holds, out of those it needs. |
Recovery | The draft spends through a recovery path. |
Unconfirmed | Your backend sees the transaction, but no block has confirmed it yet. You can still raise its fee or try to cancel it. |
Confirmed | A block confirmed the transaction. |
Deprecated | Another transaction spent one of its coins and confirmed first, or one of its coins is no longer in the wallet. This draft cannot confirm. |
Script types
SegWit (P2WSH) and Taproot (P2TR) write the same policy differently, which changes what a spend reveals, what it costs, and which devices can sign.
Descriptor registration
A signing device can check your addresses and change only once it knows the descriptor, and each device keeps that registration its own way.