LearnUnder the hood

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.

You pick SegWit (P2WSH) or Taproot (P2TR) once, when you create a wallet. The choice covers every address of the wallet.

Both script types enforce the same policy

Liana compiles your policy into Bitcoin Script with Miniscript. The script type changes how the result is written, never what it allows. In the wallet below, key A can spend at any time, and key B after 52,596 blocks (about 1 year).

One policy, two descriptors (keys abbreviated)
wsh(or_d(pk(A),and_v(v:pkh(B),older(52596))))
tr(A,and_v(v:pk(B),older(52596)))

Both lines give the same keys the same powers. On-chain, they differ only in what a spend reveals and costs.

The same Liana wallet, where key A spends at any time and key B after 52,596 blocks, committed as SegWit (P2WSH) and as Taproot (P2TR): a bc1q address holding the 32-byte SHA-256 hash of one witness script, and a bc1p address holding one 32-byte key derived under BIP 341 from internal key A and the hash of a one-leaf tree.

SegWit (P2WSH) hashes one script that holds every path

For a wsh() descriptor, Liana compiles the whole policy into one script, the witness script. The address, which starts with bc1q, holds only a 32-byte SHA-256 hash of it.

To spend, Liana puts the full script in the witness, the part of the transaction that carries signatures and scripts. Every node hashes it and compares the result with the address (BIP 141). Even an ordinary payment by A therefore reveals the whole policy: key A, a hash of key B, and the timelock.

Taproot (P2TR) hides the paths behind one key

A tr() descriptor holds an internal key and a tree of scripts, one path per leaf. The address starts with bc1p and holds a single 32-byte key. BIP 341 derives that key from the internal key and a hash of the whole tree. A coin then has two ways out:

  • Key path: The internal key signs. The witness is one 64-byte signature, with no script.
  • Script path: The witness reveals one leaf, the data that satisfies it, and a control block. The control block holds the internal key plus one 32-byte hash per level of the tree. Together they prove that the leaf belongs to the tree.

The other leaves stay hidden, so a Taproot spend reveals one path at most.

Liana makes the primary key the internal key when it can

The key path has no condition, so only a key allowed to spend alone, at any time, can be the internal key. Recovery keys never qualify.

  • One primary key: It becomes the internal key, so payments use the key path. The tree holds only the recovery paths, as in tr(A,…) above. With several primary keys and a threshold of one, one of them becomes the internal key, and each of the others a leaf.
  • Two signatures or more on the primary path: No key can spend alone, so Liana uses an unspendable internal key. The primary path becomes a leaf. Liana weights it as the most used path, so it sits right below the root, where the control block is shortest.
Two Taproot trees for the same recovery paths: with one primary key, key A is the internal key and payments use the key path, while the tree holds only the two recovery leaves; with two primary signatures or more, an unspendable internal key closes the key path and the primary leaf sits right below the root.

The unspendable key is a point nobody can sign for

BIP 341 gives a point whose x-coordinate is a hash of the curve's generator point. Nobody knows its private key, so nobody can sign with it. Liana hardcodes it:

liana/src/descriptors/analysis.rs
0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0

Liana puts the point in an xpub with no fingerprint, and derives it at /<0;1>/* like any other key. The chain code of that xpub is a SHA-256 of the tree's keys. Each address thus gets its own internal key, which looks ordinary on-chain. Only someone holding the descriptor can tell the key path is closed.

Liana's Register descriptor step lists this key as Key @0:, like any other. A Specter DIY shows it as a NUMS key, and a Ledger, from Bitcoin app 2.2.2, as a dummy or unspendable key. Liana leaves it out of the encrypted descriptor backup, so it cannot open the file. That key without a fingerprint is not a key you lost.

Liana builds its unspendable Taproot internal key from BIP 341's point H, puts it in an xpub with no fingerprint, and derives it like any key into one ordinary-looking key per address.

What each spend puts on the blockchain

Beyond signatures, each spend publishes:

SpendSegWit (P2WSH)Taproot (P2TR)
Primary path, one keyThe whole script: every path, key or key hash, and timelockNothing more, like any single-key Taproot wallet
Primary path, two signatures or moreThe whole scriptThe primary leaf and a control block
Recovery pathThe whole script, plus the recovery keys it hashedThe recovery leaf, with its keys and timelock, and a control block that shows the internal key

Under both types, a recovery spend also shows its timelock in each input, as the Privacy page explains.

Taproot payments cost least with one primary key

Both address types lock a coin with a 34-byte output script, so paying you costs the sender the same. The difference is in the witness, where a byte counts as a quarter of a vbyte (BIP 141). With timelocks of 52,596 blocks (about 1 year), each coin spent adds about:

Wallet and pathSegWit (P2WSH)Taproot (P2TR)
One primary key, one recovery key: payment77 vbytes58 vbytes
Same wallet: recovery86 vbytes76 vbytes
2-of-2 primary, 2-of-3 recovery: payment119 vbytes108 vbytes
Same wallet: recovery145 vbytes118 vbytes

At a feerate of 10 sats/vbyte, a single-key payment saves about 190 sats per coin.

Each recovery path you add lengthens a P2WSH script, and so every spend. A Taproot key-path spend stays at one signature. A leaf spend grows only with its depth, by 32 bytes (8 vbytes) per level. With two signatures or more on the primary path, payments are leaf spends. The saving then depends on the policy. Behind a 2-of-2 primary path and a single recovery key, a Taproot payment is a few vbytes larger.

The witness of each spend from a wallet with one primary key and one recovery key, to scale: 143 bytes for a SegWit (P2WSH) payment, 66 for a Taproot (P2TR) key-path payment, 178 for a SegWit (P2WSH) recovery and 140 for a Taproot (P2TR) script-path recovery.

A Taproot wallet needs Taproot support on every device

Every signing device of a Taproot wallet must be able to sign Taproot Miniscript. The Signing devices page lists the devices that can, and from which firmware. Choose a policy shows what the installer does with a device that cannot.

With Bitcoin Core as your backend, a Taproot wallet needs version 26.0 or later. lianad refuses to start with an older one.

You pick the script type once, in the installer

Requires Liana 5.0+ You pick the script type when you create the wallet, as Choose a policy shows. The script type is part of the descriptor. To switch later, you create a new wallet and move your coins, as Change a policy describes.

Next steps