Witness programs
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.
Loading lesson visuals...
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.
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 every idea above to open it.
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.
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.