LearnUnder the hood

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.

A PSBT read left to right: the magic bytes 70 73 62 74 FF, the global map holding the unsigned transaction, one map per input, and one map per output, each map closed by a 00 byte.

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 mapSegWit (P2WSH) walletTaproot (P2TR) wallet
Each inputThe coin's amount and script, the previous transaction that created it, the witness script, the fingerprint and derivation path of each keyThe 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 walletThe fingerprint and derivation path of each keyThe 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 signing device in a SegWit (P2WSH) wallet tricked into paying 1.5 BTC in fees over two signings, the previous transaction that stops it, and a Taproot (P2TR) wallet where the same lie invalidates every signature.

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

The life of a PSBT in Liana, left to right: lianad builds the draft, Liana stores it under Drafts & approvals as its reference copy, a Ledger over USB and a Coldcard by SD card each return signatures that Liana merges into that copy, then lianad finalizes the transaction and passes it to the backend.

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.psbt by 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 showsWhat it means
UnsignedNo 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 broadcastOne spending path has all its signatures, from the keys listed after Signed by, and its timelock, if any, has expired.
TimelockedA 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 & approvalsSignatures the spending path holds, out of those it needs.
RecoveryThe draft spends through a recovery path.
UnconfirmedYour backend sees the transaction, but no block has confirmed it yet. You can still raise its fee or try to cancel it.
ConfirmedA block confirmed the transaction.
DeprecatedAnother transaction spent one of its coins and confirmed first, or one of its coins is no longer in the wallet. This draft cannot confirm.
The statuses of a draft in Liana 16.0 as a state machine. The last signature leads from Unsigned to To broadcast, through Timelocked if it completes a recovery path while a coin's timelock runs. Broadcast leads to Unconfirmed, a block to Confirmed, and every status before Confirmed can fall into Deprecated.
Only a draft signed through a recovery path can stop at Timelocked, while a coin's timelock still runs. Until a block confirms it, any draft can become Deprecated.