Reviewed Aug 2026
DE
BA-06 · LESSON 05

Witness programs

KEY DEFINITIONS

Terms used in this lesson

Witness
Signatures, scripts, or other data supplied to satisfy a Bitcoin output’s spending condition.
SegWit
Segregated Witness: a Bitcoin upgrade that separates authorization data from the transaction identifier and introduces versioned witness programs.
P2WPKH
Pay to Witness Public Key Hash: a native SegWit output for one public-key hash.
P2WSH
Pay to Witness Script Hash: a native SegWit output that commits to a witness script.
Hash160
SHA-256 followed by RIPEMD-160, producing the 20-byte hash used by several Bitcoin spending conditions.
SHA-256
A cryptographic hash function used throughout Bitcoin to produce fixed-size 256-bit digests.
Taproot
A Bitcoin output and spending design that can combine a public-key path with privately committed alternative scripts.
P2SH
Pay to Script Hash, a legacy Bitcoin output template that commits to a redeem script.
P2TR
Pay to Taproot, the Bitcoin output type introduced with Taproot.
Transaction ID
The identifier produced by hashing a Bitcoin transaction’s non-witness serialization.
Witness transaction ID
An identifier that commits to a transaction including its witness data.

SegWit moves authorization data into witness structures and versions the program semantics.

35 min Difficulty 2/5 Not started

Loading lesson visuals...

01

Learn the idea

A witness program is an output script consisting of a version and a program byte string. SegWit version 0 defines P2WPKH for a 20-byte program and P2WSH for a 32-byte program. Version 1 with a 32-byte program defines Taproot under later rules. Witness data is carried separately from scriptSig and is interpreted according to the version.

GUIDED EXPLANATION1/5 ideas inspected
1

Recognize the program

A native witness output has a version opcode followed by a canonical data push. The version and program length select defined semantics.

Inspect each idea before the worked example.
The worked example follows the explanation

Inspect every idea above to open it.

Important distinctionSegWit witness data is optional metadata that full nodes ignore.

Witness data is excluded from the legacy txid, but upgraded nodes validate it as required authorization and include it in wtxid and block witness commitments.

02
FINISH LEARNING FIRST

The questions unlock after every required learning activity

Inspect every guided idea, open the worked example, rebuild its mechanism, and complete the deterministic lesson tool. Your progress is saved automatically.