<p>In the original design of Bitcoin, the conditions for spending an output would be explicitly defined in the output script (scriptPubKey). P2PK, P2PKH and bare multisig are examples of this. However, it was soon realized that this way the recipient was passing the cost of a more complex locking script onto the sender. Since then, every new output format has had a fixed size.</p>
<p>P2SH, P2WSH and P2TR-script-path require the recipient to reveal a script (which usually includes OP_CHECKSIG or other signature checks) and satisfy it. P2WPKH requires only the public key and signature, there is no script (the OP_CHECKSIG is only implicit). Finally, P2TR-key-path requires only a signature.</p>
<p>For example, this is how <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program" rel="nofollow noreferrer">BIP141</a> defines the validation of P2WPKH inputs:</p>
<blockquote>
<p>If the version byte is 0, and the witness program is 20 bytes:</p>
<ul>
<li>It is interpreted as a pay-to-witness-public-key-hash (P2WPKH) program.</li>
<li>The witness must consist of exactly 2 items (≤ 520 bytes each). The first one a signature, and the second one a public key.</li>
<li>The HASH160 of the public key must match the 20-byte witness program.</li>
<li>After normal script evaluation, the signature is verified against the public key with CHECKSIG operation. The verification must result
in a single TRUE on the stack.</li>
</ul>
</blockquote>
<p>As you can see, even though the specification references opcodes to denote cryptographic operations, no script execution actually takes place.</p>

CC BY-SA 4.0
2023-03-03T15:13:22.233Z
2023-03-05T00:01:45.463Z
2023-03-05T00:01:45.463Z
Vojtěch Strnad
<p>When I create a segwit transaction v0 (P2WPKH) or v1 (P2TR key-path spend) I do like that (let's spend a P2TR output):</p>
<ul>
<li>Locking Script (of the P2TR output I'm spending): OP_1 PK_size PK</li>
<li>Witness: 1 (witness_count) SIG_size SIG</li>
</ul>
<p>So I'm wondering, the op code CHECKSIG is automatically added when nodes verify this transaction?</p>
<p>Because with legacy P2PKH transaction you have:</p>
<ul>
<li>Locking Script (of the P2PKH output I'm spending): dup + hash_160 + pk_hash_size + pk_hash + equalverify + checksig</li>
<li>Unlocking Script: SIG_size SIG PK_size PK</li>
</ul>
<p>So in this case (P2PKH) there explicitly is the OP_CHECKSIG in the locking script.</p>
<p>Thanks in advance!</p>

<segregated-witness><signature><taproot><p2tr><checksig>
Validation of segwit v0-v1 tx automatically adds OP_CHECKSIG?
alemaz98
# Validation of segwit v0-v1 tx automatically adds OP_CHECKSIG?

(Asked by: username_0 on 2023-03-03)

When I create a segwit transaction v0 (P2WPKH) or v1 (P2TR key-path spend) I do like that (let's spend a P2TR output):

* Locking Script (of the P2TR output I'm spending): OP\_1 PK\_size PK
* Witness: 1 (witness\_count) SIG\_size SIG

So I'm wondering, the op code CHECKSIG is automatically added when nodes verify this transaction?

Because with legacy P2PKH transaction you have:

* Locking Script (of the P2PKH output I'm spending): dup + hash\_160 + pk\_hash\_size + pk\_hash + equalverify + checksig
* Unlocking Script: SIG\_size SIG PK\_size PK

So in this case (P2PKH) there explicitly is the OP\_CHECKSIG in the locking script.

Thanks in advance!

**Tags:** segregated-witness, signature, taproot, p2tr, checksig


---

## 1 answers

### Answer by username_1 on 2023-03-03. Score: 3 | Accepted answer

In the original design of Bitcoin, the conditions for spending an output would be explicitly defined in the output script (scriptPubKey). P2PK, P2PKH and bare multisig are examples of this. However, it was soon realized that this way the recipient was passing the cost of a more complex locking script onto the sender. Since then, every new output format has had a fixed size.

P2SH, P2WSH and P2TR-script-path require the recipient to reveal a script (which usually includes OP\_CHECKSIG or other signature checks) and satisfy it. P2WPKH requires only the public key and signature, there is no script (the OP\_CHECKSIG is only implicit). Finally, P2TR-key-path requires only a signature.

For example, this is how [BIP141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program) defines the validation of P2WPKH inputs:

> If the version byte is 0, and the witness program is 20 bytes:
>
> * It is interpreted as a pay-to-witness-public-key-hash (P2WPKH) program.
> * The witness must consist of exactly 2 items (≤ 520 bytes each). The first one a signature, and the second one a public key.
> * The HASH160 of the public key must match the 20-byte witness program.
> * After normal script evaluation, the signature is verified against the public key with CHECKSIG operation. The verification must result
>   in a single TRUE on the stack.

As you can see, even though the specification references opcodes to denote cryptographic operations, no script execution actually takes place.


---

