<p>I don't see why that scriptPubKey would be incorrectly marked as P2TR as it absolutely does not follow the expected pattern. BIP 341 is very unambiguous as to the script construction - it must be OP_1 followed by a push of exactly 32 bytes.</p>
<p>The erroneously marked P2TR script is only a push of 36 bytes. It does not begin with OP_1, and the length of the data push is incorrect.</p>
<blockquote>
<p>Is the only solution to check witness stack for the right pattern?</p>
</blockquote>
<p>No. A transaction can consist of entirely non-segwit inputs and still create P2TR outputs. Such a transaction would not have any witness data.</p>

CC BY-SA 4.0
2024-03-02T05:16:25.390Z
2024-03-02T05:16:25.390Z
Ava Chow
<p>The scriptpubkey alone can be used to identify the type of address. However, I'm debugging a library that's having difficulty differentiating the following transaction/scriptpubkey from a p2tr transaction/scriptpubkey.</p>
<p><strong>Erroneously marked p2tr:</strong></p>
<p>Txid: <a href="https://blockstream.info/tx/2b3733a39b87cef1f7c2ca8988583ec0c1a886651b040e3dbaf4c26be81d0f75?expand" rel="nofollow noreferrer">2b3733a39b87cef1f7c2ca8988583ec0c1a886651b040e3dbaf4c26be81d0f75:195</a></p>
<p>Scriptpubkey: 245a227ef640f3b1dc1815e6e39b482677f0f57b69de7775faec778c0950a8851805000000</p>
<p><strong>Correctly marked p2tr:</strong></p>
<p>Txid: <a href="https://blockstream.info/tx/83c8e0289fecf93b5a284705396f5a652d9886cbd26236b0d647655ad8a37d82?expand" rel="nofollow noreferrer">83c8e0289fecf93b5a284705396f5a652d9886cbd26236b0d647655ad8a37d82:0</a></p>
<p>Scriptpubkey: 5120a457d0c0399b499ed2df571d612ba549ae7f199387edceac175999210f6aa39d</p>
<p>And honestly.. I understand why the library is having issues. The problematic scriptpubkey does look like a p2tr (1, data). However one thing I noticed is the problematic tx doesn't have witness (predates segwit). Is the only solution to check witness stack for the right pattern?</p>

CC BY-SA 4.0
2024-03-03T19:14:51.377Z
A witness stack is part of an input’s data. If you are trying to identify an output, how does the witness stack come into play? Are you trying to figure out whether an input is spending a P2TR output?
Murch
<script><p2tr><non-standard-transaction>
How to identify P2TR output type?
arshbot
# How to identify P2TR output type?

(Asked by: username_0 on 2024-03-02)

The scriptpubkey alone can be used to identify the type of address. However, I'm debugging a library that's having difficulty differentiating the following transaction/scriptpubkey from a p2tr transaction/scriptpubkey.

**Erroneously marked p2tr:**

Txid: [2b3733a39b87cef1f7c2ca8988583ec0c1a886651b040e3dbaf4c26be81d0f75:195](https://blockstream.info/tx/2b3733a39b87cef1f7c2ca8988583ec0c1a886651b040e3dbaf4c26be81d0f75?expand)

Scriptpubkey: 245a227ef640f3b1dc1815e6e39b482677f0f57b69de7775faec778c0950a8851805000000

**Correctly marked p2tr:**

Txid: [83c8e0289fecf93b5a284705396f5a652d9886cbd26236b0d647655ad8a37d82:0](https://blockstream.info/tx/83c8e0289fecf93b5a284705396f5a652d9886cbd26236b0d647655ad8a37d82?expand)

Scriptpubkey: 5120a457d0c0399b499ed2df571d612ba549ae7f199387edceac175999210f6aa39d

And honestly.. I understand why the library is having issues. The problematic scriptpubkey does look like a p2tr (1, data). However one thing I noticed is the problematic tx doesn't have witness (predates segwit). Is the only solution to check witness stack for the right pattern?

**Tags:** script, p2tr, non-standard-transaction

> **Comments:**
> **username_1**: A witness stack is part of an input’s data. If you are trying to identify an output, how does the witness stack come into play? Are you trying to figure out whether an input is spending a P2TR output?  

---

## 1 answers

### Answer by username_2 on 2024-03-02. Score: 4

I don't see why that scriptPubKey would be incorrectly marked as P2TR as it absolutely does not follow the expected pattern. BIP 341 is very unambiguous as to the script construction - it must be OP\_1 followed by a push of exactly 32 bytes.

The erroneously marked P2TR script is only a push of 36 bytes. It does not begin with OP\_1, and the length of the data push is incorrect.

> Is the only solution to check witness stack for the right pattern?

No. A transaction can consist of entirely non-segwit inputs and still create P2TR outputs. Such a transaction would not have any witness data.


---

