Witness Script
A witness script is the full spending script whose SHA-256 hash a pay-to-witness-script-hash output commits to, revealed only when the coins are spent. The 32-byte commitment keeps arbitrarily complex conditions, a 2-of-3 multisig, a timelock, a Lightning contract, hidden behind a uniform hash until spend time. It is SegWit's counterpart to the redeem script of legacy P2SH.
Why it matters
Witness scripts are how most sophisticated bitcoin arrangements were deployed between 2017 and the Taproot era: multisignature treasuries, Lightning channel contracts, and inheritance timelocks all live as witness scripts behind P2WSH addresses. The sender never needs to know or care what conditions govern the coins; they pay a hash, and the burden of satisfying the script falls entirely on the future spender.
The move from P2SH's 20-byte hash to a 32-byte one also closed a security gap, restoring full collision resistance for scripts involving multiple parties.
How it works
The spender's witness stack supplies the required signatures and data, followed by the serialized witness script itself. Validating nodes hash the script, check it matches the output's commitment, then execute it against the supplied items. Only at that moment do the coins' true spending conditions become public, which is also why unspent P2WSH outputs reveal nothing about their governance.
Ready to convert your gold to Bitcoin?
Get Your Free Kit →