<blockquote>
<ol>
<li>It is still not clear to me what tx version number a Taproot transaction uses.</li>
</ol>
</blockquote>
<p>Any transaction version number can have Taproot inputs or outputs.</p>
<blockquote>
<ol start="3">
<li>Is there a way to know via the ins (via getrawtransaction RPC call) if it's a TPR transaction?</li>
</ol>
</blockquote>
<p>There is no such thing as a &quot;Taproot transaction&quot;; there are Taproot outputs and Taproot inputs. Transactions can freely mix Taproot inputs with other inputs, and Taproot outputs with other outputs.</p>
<p>Taproot outputs can be recognized by having a scriptPubKey consisting of OP_1 followed by a 32-byte push.</p>
<p>Taproot inputs are defined as just inputs that spend taproot outputs. It is for now possible to recognize them just based on input data, though this is not guaranteed to remain possible with future upgrades:</p>
<ul>
<li>If an input has exactly one witness stack item (after removing the optional annex, if any), it is either a Taproot key path spend, or a strange zero-input P2WSH spend.</li>
<li>If an input has two or more witness stack items (after removing the optional annex, if any), and the last item of those starts with byte 0xc0 or 0xc1, it is a BIP342 taproot script path spend (such an input cannot possibly be a P2WPKH spend as the prefix bytes are not valid public key header bytes, and not P2WSH spends, because those prefix bytes are invalid in script).</li>
</ul>

CC BY-SA 4.0
2023-09-25T17:06:07.613Z
A P2WSH input whose witness script is satisfied by an empty initial stack will also have exactly one witness stack item. These are obviously rare, but it still means the heuristic is not perfect. Same goes for inputs spending unknown witness versions which can have any number of witness stack items (and are non-standard). You can somewhat improve the heuristic by only considering inputs whose single witness stack item has 64 or 65 bytes (in case of 65 bytes check that the last byte is an allowed sighash flag).
Vojtěch Strnad
CC BY-SA 4.0
2023-09-25T17:12:44.083Z
@VojtěchStrnad Oh yes, you're right.
Pieter Wuille
CC BY-SA 4.0
2023-09-25T15:04:48.303Z
2023-09-26T11:54:21.213Z
2023-09-26T11:54:21.213Z
Pieter Wuille
<p>I'm trying to &quot;distill&quot; Taproot transactions in the raw transaction output, but:</p>
<ol>
<li>It is still not clear to me what tx version number a Taproot transaction uses.</li>
<li>How to find out if it's a taproot transaction containing an inscription (in the witness) or just a normal tx with taproot signaled.</li>
<li>Is there a way to know via the inputs (via getrawtransaction RPC call) if it's a TPR transaction?</li>
</ol>

<taproot><witness-data><ordinals><getrawtransaction>
How can I tell from the `getrawtransaction` if a transaction signaled Taproot?
Bart DV
# How can I tell from the `getrawtransaction` if a transaction signaled Taproot?

(Asked by: username_0 on 2023-09-25)

I'm trying to "distill" Taproot transactions in the raw transaction output, but:

1. It is still not clear to me what tx version number a Taproot transaction uses.
2. How to find out if it's a taproot transaction containing an inscription (in the witness) or just a normal tx with taproot signaled.
3. Is there a way to know via the inputs (via getrawtransaction RPC call) if it's a TPR transaction?

**Tags:** taproot, witness-data, ordinals, getrawtransaction


---

## 1 answers

### Answer by username_1 on 2023-09-25. Score: 4

> 1. It is still not clear to me what tx version number a Taproot transaction uses.

Any transaction version number can have Taproot inputs or outputs.

> 3. Is there a way to know via the ins (via getrawtransaction RPC call) if it's a TPR transaction?

There is no such thing as a "Taproot transaction"; there are Taproot outputs and Taproot inputs. Transactions can freely mix Taproot inputs with other inputs, and Taproot outputs with other outputs.

Taproot outputs can be recognized by having a scriptPubKey consisting of OP\_1 followed by a 32-byte push.

Taproot inputs are defined as just inputs that spend taproot outputs. It is for now possible to recognize them just based on input data, though this is not guaranteed to remain possible with future upgrades:

* If an input has exactly one witness stack item (after removing the optional annex, if any), it is either a Taproot key path spend, or a strange zero-input P2WSH spend.
* If an input has two or more witness stack items (after removing the optional annex, if any), and the last item of those starts with byte 0xc0 or 0xc1, it is a BIP342 taproot script path spend (such an input cannot possibly be a P2WPKH spend as the prefix bytes are not valid public key header bytes, and not P2WSH spends, because those prefix bytes are invalid in script).

> **Comments:**
> **username_2**: A P2WSH input whose witness script is satisfied by an empty initial stack will also have exactly one witness stack item. These are obviously rare, but it still means the heuristic is not perfect. Same goes for inputs spending unknown witness versions which can have any number of witness stack items (and are non-standard). You can somewhat improve the heuristic by only considering inputs whose single witness stack item has 64 or 65 bytes (in case of 65 bytes check that the last byte is an allowed sighash flag).  
> **username_1**: @username_2 Oh yes, you're right.  

---

