BITCOIN MAINNETLive explorer status
PROGRAMMABLE LOCKS

Witness data

The witness is the part of a SegWit transaction holding signatures and unlocking data. It sits outside the txid and is discounted. Learn how it works.

What's in it

For each input, the witness holds a list of items: the data needed to satisfy that input's lock.

SpendingTypical witness items
P2WPKHsignature, public key
P2WSH multisigempty item, signatures, the witness script
Taproot key pathone 64-byte signature
Taproot script pathscript inputs, the script, a control block

Where it sits

In serialized transactions, the witness comes after the outputs and before the locktime. See Anatomy of a raw transaction.

Witness data sits outside the part used for the txidVersion4 BInputsvariesOutputsvariesWitnessvariesLocktime4 B
Witness data sits outside the part used for the txid

Committed separately

Because the txid excludes the witness, blocks need another way to commit to it. The The coinbase transaction includes a witness commitment: an OP_RETURN data outputs output holding the merkle root of every transaction's wtxid (the hash that includes witness data).

Discounted

Witness bytes count as 1 weight unit instead of 4. See Transaction size, weight and vbytes.

Reading a witness on MyBitcoinExplorer

Open any SegWit transaction and look at the raw data: after the outputs comes a witness stack for each input. For a typical bc1q spend it holds two items: a signature (about 71 bytes) and a public key (33 bytes).

Why witness data could be discounted

Witness data is needed to validate a transaction once, but it doesn't change the UTXO set nodes must keep. Discounting it rewards transactions that put less long-term burden on every node.

Share this guide
Share on X ↗

Key takeaways

  • The witness carries each input's unlocking data.
  • It's excluded from the txid but committed via the coinbase witness commitment.
  • Witness bytes are discounted to a quarter weight.

Common questions

Do legacy transactions have witness data?

No. Their unlocking data is in the scriptSig inside each input.

What is a wtxid?

A hash of the full transaction including witness data.

Is witness data stored forever?

It is part of each block, so archival nodes keep it; pruned nodes eventually delete old blocks including witnesses.

Do legacy inputs have witnesses?

No. Their unlocking data is inside the input's scriptSig.